简体   繁体   English

如何停止自动下载的html5音频

[英]How can i stop html5 audio from auto download

I am using this 我正在用这个

<audio src="audio.mp3" />

Now that file is big and system automatically downloads it when someone loads the page. 现在该文件很大,有人加载页面时系统会自动下载它。

is there any way that when someone press play , only then system downlaods. 当有人按下play时,是否有任何方法会破坏系统。 Because that player is in my every page and it wastes the BW 因为那个玩家在我的每一页中,浪费了带宽

You can use the preload='none' attribute. 您可以使用preload='none'属性。 Documentation here 这里的文件

The "none" attribute: "none"属性:

Hints to the user agent that either the author does not expect the user to need the media resource, or that the server wants to minimise unnecessary traffic. 提示用户代理作者不希望用户需要媒体资源,或者服务器希望最大程度地减少不必要的流量。 This state does not provide a hint regarding how aggressively to actually download the media resource if buffering starts anyway (eg once the user hits "play"). 此状态没有提供关于如果缓冲无论如何开始(例如,一旦用户点击“播放”)实际实际下载媒体资源的积极程度的提示。

Your HTML could look something like this: 您的HTML可能看起来像这样:

<audio preload="none">
  <source src="audio.mp3" type="audio/mpeg" />
  Your browser does not support this audio type.
</audio> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM