How can I find out if jPlayer is playing? I tried this alert($.jPlayer.event.playing);
but it doesn't work.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
由
翻译强力驱动
问题:
回答1:
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
回答2:
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
回答3:
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.
回答4:
var duration = $('#jquery_jplayer_1').data("jPlayer").status.currentTime; if(duration){ // Source is loaded and playing }