$.jPlayer.timeFormat.showHour = true;
$(".jp-jplayer").each(function() {
- console.log('starting player')
var $self = $(this);
var $root = $self.parent();
var $currentMedia = null
var player = null;
var setMedia = function(elem, time=0) {
- console.log('setMedia', elem, time);
var media = {}
media['mp3'] = elem.attr('data-mp3');
player.jPlayer("pause", time);
$currentMedia = elem;
- $(".play-prev", $root).prop("disabled", !elem.prev().length);
$(".play-next", $root).prop("disabled", !elem.next().length);
let du = elem.data('duration');
ready: function() {
player = $(this);
- console.log(1);
let selectItem = $('.c-select li');
selectItem.on('click', function() {
let p = $currentMedia.prev();
if (p.length) {
setMedia(p).jPlayer("play");
+ } else {
+ // If in first part, restart it.
+ setMedia($currentMedia).jPlayer("play");
}
});
audiobooks = {};
}
if (t && event.jPlayer.status.duration - t > 10) {
- console.log('writer');
audiobooks[$root.attr("data-book-slug")] = [
Date.now(),
event.jPlayer.status.media.id,