Can someone show me how to add this code to the rest of the code

This is the code, I don’t know how to add it to the rest of the code, can someone show me?

**[** myaud=document.getElementById("player");myaud.volume=1.0; **]**

<button style="cursor: pointer; background-color:transparent;padding-bottom:1px;"
onclick="document.getElementById('player').play()">Play</button>

<audio id="player" preload="none" style="display:none;">
<source src='http://air.radiorecord.ru:8101/rr_320' type='audio/mpeg'/>
</audio>
</div>
...other HTML
  <script>
    myaud = document.getElementById("player");
    myaud.volume = 1.0;
  </script>
</body>
1 Like

Can you show me a jsfiddle of it working cause I have volume at 0.0 and there’s still audio coming out.

All I’ve done there is show you how to attach the JavaScript you created to your HTML page. Looking at the code itself (which I’ve not touched), it doesn’t appear to have any event associated with it to trigger the behaviour you want to happen.

Someone helped me get it to work:

<script>
function setControls() {
    myaud=document.getElementById("player");
    myaud.play();
    myaud.volume=0.0;
  }
</script>

<button style="cursor: pointer; background-color:blue;padding-bottom:1px;"
onclick="setControls()">Play</button>

<audio controls id="player" preload="none" style="display:none;">
<source src='http://air.radiorecord.ru:8101/rr_320' type='audio/mpeg'/>
</audio>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.