如何禁用音频(流)html5元素的自动播放 [英] How to disable autoplay of audio (stream) html5 element

查看:450
本文介绍了如何禁用音频(流)html5元素的自动播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法完成这项工作,我尝试了多种方法,到目前为止,这些建议可能适用于静态mp3和其他文件,但对于此流,隐藏了控件,我无法停止自动播放,我尝试过的任何内容。

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.

请查看此 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。它是一个流,但你可能听不到任何声音,除非我的区域有一些活动,但要查看流是否自动播放,我使用了Google Chrome的Inspect,而不是检查网络标签,你会看到该流是加载...

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...

截图流连续加载

推荐答案

解决方案是使用这样的预加载属性:

The solution was to use preload atribute like this:

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

这篇关于如何禁用音频(流)html5元素的自动播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆