player.setVolume(0.0) & player.setMuted(true) not working?

So i’ve been looking into creating something for Apex Legends and would like to embed a couple of streamers on the main page so people can discover them easier.

What i’ve been trying to do is:

<script src= "https://player.twitch.tv/js/embed/v1.js"></script>
<div id="ChannelDiv"></div>
<script type="text/javascript">
	var options = {
	width: 500,
	height: 500,
	channel: "shroud",
};
var player = new Twitch.Player("ChannelDiv", options);
player.setVolume(0.0);
</script>

But the “player.setVolume(0.0);” doesn’t really do anything, i’ve tried “player.setMuted(true)” as well.

Is there a way to fix it or at least mute the player in some way?

There is nothing “wrong” with you code. That I can fine.

The problem is that the user/viewer has to have interacted with the player first.

Before control is granted. (Tested in google chrome)

  • Open the code
  • Change the player volume once as a user
  • Progmatic changes now work

But for me the player is starting muted so I don’t need to mute it.

This is due to changes in how browsers deal with auto play.

1 Like

I tried doing that, i tried loading the page and manually change the volume/mute it etc.

Even after doing that, it doesn’t load it every next time with specific volume set in the code.

It’s weird.

That is also the behaviour I have observed.

Generally after a refresh it resets to force muted and the JS doesn’t work to reset.

Thats the state of auto playing video in browsers these days

Weird, i’ll have to look into a possible workaround but it seems grim that i’ll find a solution.

Will post if i find a workaround.

If you find a workaround it’s a bug in chromium which will get fixed.

And then you’d need to find a new work around…

Basically you can’t set the volume until the user interacts. it is weird that it doesn’t raise any console errors reporting this issue. So the Twitch embed library might be handling this internally with no feedback.

But it won’t help you to auto play and unmute the audio.

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