Javascript Unmute Sound

No, I did not mean that, I meant exactly before

which is the line that start reproducing the video? you did not answer that

videoElem.play();
So you mean this:

<script>
    const videoElem = document.getElementById('myVideo');
    const playPauseButton = document.getElementById('btnPlay');

    
    playPauseButton.addEventListener('click', () => {
      if (videoElem.paused) {
        videoElem.muted = false;
        videoElem.play();
        playPauseButton.textContent = 'Pause';
        playPauseButton.classList.add('transparent');
      } else {
        videoElem.pause();
        playPauseButton.textContent = 'Play';
        playPauseButton.classList.remove('transparent');
        videoElem.muted = !videoElem.muted;
      }
    });
  
    </script>

yes. Does it work? I can only guess, not having something to reproduce

no very knowledgeable one

any other ideas?

can you put up a github repo? I can’t reproduce only with copy and pasting here

This is the repository:

@hasanzaib1389 @ILM its been quite quiet recently…

Not sure if you saw the repository

please stop pinging, I’m not online all the time, and it takes time to set up and test a website

I don’t experience the popup to unmute, but the video reproduce with sound
maybe check your browser settings?

The popup does not unmute the video for you too?

You didn’t add any code for the popup, and it is just on the page, with no handlers for the buttons. Update the repo if you have new code that isn’t in it.


As far as I know, the video should play with audio when the playback is initiated by a user interaction (i.e. the play button). As long as it doesn’t have the autoplay attribute, which also requires the muted attribute in most browsers, it seems. If you are trying to unmute an autoplaying video, that is a different issue.

I don’t see no popup

Its not made with css on that repository so it just appears below the video

Thanks for the article. It doesn’t seem to deal with unmuting an autoplaying video though

the video plays unmuted for me

which happens after you hit play? or did you add any other code?

Can you show me how it looks on your side of things?

I used exactly the code you gave. Pressing play it plays with sound

How did you transcribe the code