This is expected, browser’s autoplay policy will not allow us to trick this way as mentioned here in stackoverflow:
I have a full topic here, regarding audio autoplay:
As per that you have 2 options:
-
Always do getUserMedia() i.e GUM request before playing the streams, by doing this browser allows playing the stream without any autoplay issues, this will always work
-
If you don’t want to do GUM then before playing video you must ask user for interaction, show a modal and show some text and a button when user clicks that button play the stream it will work. The only problem is that it will only work for the streams being played right after that button click, and if you have stream like few seconds after that and you want to play then you will again face autoplay issue for this specific stream. So if you have 1 stream and want to avoid autoplay, do this otherwise do the first one GUM that will surely work.