jPlayer - how to find out if it's playing

独自空忆成欢 提交于 2019-12-05 06:51:13

Kyle's method works fine, here's a fiddle to demonstrate it in action: http://jsfiddle.net/75lb/95EPu/

However, ordinarily you wouldn't need to access jPlayer's internals like this, being an event-driven plugin.. would it be cleaner to respond to one of jPlayer's many events (at the appropriate moment)? http://www.jplayer.org/latest/developer-guide/#jPlayer-events

I've not worked with Jplayer specifically, but playing around, this returned false if the media was playing and true if it wasn't.

$('#jquery_jplayer_1').data().jPlayer.status.paused

On my setup, I noticed the class "jp-state-playing" was added to the div that included jp-audio. I have not done a lot of research, but querying for a null object or not seemed better than tying myself to jPlayers internals.

var duration = $('#jquery_jplayer_1').data("jPlayer").status.currentTime;

if(duration){
  // Source is loaded and playing 
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!