jplayer在jquery中的特定时间百分比之间播放 [英] jplayer play between certain percents of time in jquery
问题描述
我知道我可以在给定的时间点或通过执行以下操作按百分比启动jPlayer:
I know I can start jPlayer at a given point in time or by percent by doing:
$("#jquery_jplayer").jPlayer("playHead", 30);
这是发出播放命令的时候(可以正常工作),但是我如何通过绝对时间或百分比来限制两个固定点之间的播放时间呢?也就是说,我希望它以30%开始,以50%结尾,依此类推.基本上,这只是一首好听的音乐片段.有什么想法或建议吗?
This is when issuing the play command (works fine), but how can I constrain the play time between two fixed points, either by absolute time or percent is fine? Ie I want it to start at 30% and end at 50%, etc. Basically just a good snippet of a song. Any ideas or pointers?
http://www.happyworm.com/jquery/jplayer/latest/developer-guide.htm#jPlayer-playHead
推荐答案
在jPlayer 1.2中(不是最新的),您应该有一个"onProgressChange"事件(用于更新playdTime文本),因此如果您有一个全局(gasp) )像
Well in jPlayer 1.2 (not newest) you should have an "onProgressChange" event (used for updating the playedTime text), so if you had a global (gasp) var like
var demoSong = true;
然后您可以使onProgressChange函数看起来像这样
Then you could make your onProgressChange function look like this
$("#jquery_jplayer").jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
jpPlayTime.text($.jPlayer.convertTime(playedTime));
jpTotalTime.text($.jPlayer.convertTime(totalTime));
if(demoSong) {
if(playedPercentAbsolute > 50) {
$("#jquery_jplayer").jPlayer("stop");
}
}
});
我正在将网站转换为jPlayer 2.0,并且事件绑定的更改将使此答案无益.也许它可以为您提供一个开端.
I'm in the middle of converting my site to jPlayer 2.0 and the changes in event binding will make this answer unhelpful going forward. Maybe it can give you a head start though.
这篇关于jplayer在jquery中的特定时间百分比之间播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!