Fix audiobook player position loading.
authorRadek Czajka <rczajka@rczajka.pl>
Wed, 23 Dec 2020 14:07:51 +0000 (15:07 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Wed, 23 Dec 2020 14:07:51 +0000 (15:07 +0100)
src/catalogue/static/player/player.js

index 64a21d2..69870bb 100644 (file)
@@ -29,7 +29,7 @@
 
                 $('.play-next', $root).click(function() {
                     var next = parseInt($number.text()) + 1;
-                    var p = $('.play:eq(' + next + ')', $root);
+                    var p = $('.jp-playlist .play:eq(' + (next - 1) + ')', $root);
                     if (p.length) {
                         setMedia(p).jPlayer("play");
                         $number.text(next)
                     var next = parseInt($number.text()) - 1;
                     if (next < 1)
                         return;
-                    var p = $('.play:eq(' + next + ')', $root);
+                    var p = $('.jp-playlist .play:eq(' + (next - 1) + ')', $root);
                     setMedia(p).jPlayer("play");
                     $number.text(next)
                 });
 
-                var initialElem = $('.play', $root).first();
+                var initialElem = $('.jp-playlist .play', $root).first();
                 var initialTime = 0;
                 if (Modernizr.localstorage) {
                     try {
@@ -61,6 +61,7 @@
                     if (last) {
                         initialElem = $('[data-media-id="' + last[1] + '"] .play', $root).first();
                         initialTime = last[2];
+                        $number.text($(".jp-playlist .play", $root).index(initialElem) + 1);
                     }
                 }
                 setMedia(initialElem, initialTime);