我正在使用jplayer并在页面加载时加载所有mp3文件。它不仅减慢了页面加载速度,还消耗了带宽。用户点击播放按钮后,有没有一种方法可以让jplayer下载并播放mp3。或者我是否必须使用能够传输音频文件的播放器。
答案 0 :(得分:2)
jPlayer中有一个preload选项:
The jPlayer constructor option jPlayer({preload}) is used to control
when jPlayer begins downloading new media. Some browsers will begin
the download for the whole media when the preload option is "metadata".
Others will require that "auto" is used. The only way to ensure
download does not begin automatically is to use the preload option "none".
Remember that, the media may not download as it depends on the browser
you are using. Mobile browser such as Mobile Safari on iOS 4.2 require
a gesture before any media is downloaded or played. ie., The user must
press a button to initiate the load or play operations the 1st time.
或者,您可以在没有mp3的情况下让播放器停止初始页面加载,只在用户点击播放时添加它。有关将媒体加载到播放器的示例,请参阅此演示:http://jplayer.org/latest/demo-02-jPlayerPlaylist/