How to disable autoplay of audio (stream) html5 element

纵饮孤独 提交于 2019-12-25 18:14:35

问题


I can't make this work, and I tried multiple methods, so far the suggestions maybe worked for static mp3 and other files, but for this stream, with controlls hidden I couldn't stop the autoplay, anything I tried.

Please check this jsfiddle

<audio id="player" autostart="0" autostart="false" name="media"><source id="liveatc_source" src="http://mtl2.liveatc.net/lrsb" type="audio/mpeg"></audio>

PS. it's a stream but you will probably not hear anything, unless there is some activity in my area, but to see if the stream autoplays or not, I used Inspect of Google chrome, and than check the Network tab, you will see the stream is loading coninously...

screenshot stream loading continously


回答1:


The solution was to use preload atribute like this:

<audio id="player" autostart="0" autostart="false" preload ="none" name="media">


来源:https://stackoverflow.com/questions/45132220/how-to-disable-autoplay-of-audio-stream-html5-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!