I am using jplayer and it loads all mp3 files on page load. Its not only slowing down page loading but also eating up bandwidth. Is there a way that jplayer downloads and play mp3 after user clicks play button. OR do I have to use a player that will stream audio files.

有帮助吗?

解决方案

There is a preload option in jPlayer:

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.

jPlayer-option-preload

Alternatively you can leave the player without mp3 for initial page load and only add it when the user clicks play. See this demo for an example of loading media to the player: http://jplayer.org/latest/demo-02-jPlayerPlaylist/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top