JPlayer 2.0 Elapsed / Remaining Time

I am working with jPlayer 2.0

I have a game, pause, etc ... but how do I get the elapsed / remaining attributes from a jquery object? I tried event handlers and even provided HTML elements with default selectors, but none of them work.

Thanks in advance!

+7
source share
1 answer

I did it as follows:

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 thing is that the timeupdate event dispatches a status object with duration and currentTime properties that contain exactly what you need. The event is fired 4 times per second.

$.jPlayer.convertTime converts equal seconds (4225) to hours: minutes: seconds (01:10:25).

I donโ€™t know for sure whether it was available in version 2.0, but in jPlayer 2.1.0 which I use it is written in docs ,

+12
source

All Articles