jPlayer 2.0 Elapsed/Remaining Time

僤鯓⒐⒋嵵緔 提交于 2020-01-13 08:54:32

问题


I'm working with jPlayer 2.0

I've got it playing, pausing, etc...but how do I grab the elapsed/remaining time attributes from the jquery object? I've tried the event handlers and even provided HTML elements with the default selectors, but none of that appears to work.

Thanks in advance!


回答1:


I did it this way:

self.update_timer = function (event) {
    var status = event.jPlayer.status;
    $('.jtimer').text($.jPlayer.convertTime(status.duration - status.currentTime));
};


$('.jplayer')
    .jPlayer('setMedia', {
        mp3: mp3_link
     })
    .jPlayer('play')
    .bind($.jPlayer.event.timeupdate, self.update_timer);

The important is that timeupdate event sends status object with duration and currentTime properties that contain exactly what you need. The event is fired 4 times per second.

$.jPlayer.convertTime converts plain seconds (4225) into hours:minutes:seconds (01:10:25).

I don't know exactly if this was available in 2.0, but in jPlayer 2.1.0 that I use this is written in the docs.



来源:https://stackoverflow.com/questions/6377441/jplayer-2-0-elapsed-remaining-time

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