2024-11-11 03:15:12 +01:00
|
|
|
diff --git a/src/playlist/playlist.js b/src/playlist/playlist.js
|
2024-11-13 07:35:05 +01:00
|
|
|
index 82112fb..bf39681 100644
|
2024-11-11 03:15:12 +01:00
|
|
|
--- a/src/playlist/playlist.js
|
|
|
|
+++ b/src/playlist/playlist.js
|
2024-11-13 07:35:05 +01:00
|
|
|
@@ -81,10 +81,11 @@ Object.assign(MediaElementPlayer.prototype, {
|
2024-11-11 03:15:12 +01:00
|
|
|
|
|
|
|
player.endedCallback = () => {
|
|
|
|
if (player.currentPlaylistItem < player.listItems.length) {
|
|
|
|
- player.setSrc(player.playlist[++player.currentPlaylistItem]);
|
|
|
|
+ player.setSrc(player.playlist[++player.currentPlaylistItem].src);
|
|
|
|
player.load();
|
|
|
|
setTimeout(() => {
|
2024-11-13 07:35:05 +01:00
|
|
|
- player.play();
|
|
|
|
+ var _promise = player.play();
|
|
|
|
+ console.log("play() returned promise at 'player.endedCallback': ", _promise);
|
|
|
|
}, 200);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
@@ -172,7 +173,17 @@ Object.assign(MediaElementPlayer.prototype, {
|
|
|
|
player.currentPlaylistItem = this.getAttribute('data-playlist-index');
|
|
|
|
player.setSrc(this.value);
|
|
|
|
player.load();
|
|
|
|
- player.play();
|
|
|
|
+ var isPlaying = player.media.currentTime > 0 && !player.media.paused && !player.media.ended && player.media.readyState > player.media.HAVE_CURRENT_DATA;
|
|
|
|
+ if(isPlaying) {
|
|
|
|
+ console.log("play() at 'inputs[i].addEventListener' not executed, because media is already playing");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ var _promise = player.play();
|
|
|
|
+ console.log("play() returned promise at 'inputs[i].addEventListener': ", _promise);
|
|
|
|
+ _promise.catch((error) => {
|
|
|
|
+ console.error(error);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (player.isVideo && player.options.autoClosePlaylist === true) {
|
|
|
|
mejs.Utils.toggleClass(player.playlistLayer, `${player.options.classPrefix}playlist-hidden`);
|
|
|
|
@@ -224,7 +235,8 @@ Object.assign(MediaElementPlayer.prototype, {
|
|
|
|
if (player.playlist[--player.currentPlaylistItem]) {
|
|
|
|
player.setSrc(player.playlist[player.currentPlaylistItem].src);
|
|
|
|
player.load();
|
|
|
|
- player.play();
|
|
|
|
+ var _promise = player.play();
|
|
|
|
+ console.log("play() returned promise at 'player.prevPlaylistCallback': ", _promise);
|
|
|
|
} else {
|
|
|
|
++player.currentPlaylistItem;
|
|
|
|
}
|
|
|
|
@@ -249,7 +261,8 @@ Object.assign(MediaElementPlayer.prototype, {
|
|
|
|
if (player.playlist[++player.currentPlaylistItem]) {
|
|
|
|
player.setSrc(player.playlist[player.currentPlaylistItem].src);
|
|
|
|
player.load();
|
|
|
|
- player.play();
|
|
|
|
+ var _promise = player.play();
|
|
|
|
+ console.log("play() returned promise at 'player.nextPlaylistCallback': ", _promise);
|
|
|
|
} else {
|
|
|
|
--player.currentPlaylistItem;
|
|
|
|
}
|
|
|
|
@@ -312,7 +325,8 @@ Object.assign(MediaElementPlayer.prototype, {
|
|
|
|
if (playedItems.indexOf(randomItem) === -1) {
|
|
|
|
player.setSrc(player.playlist[randomItem].src);
|
|
|
|
player.load();
|
|
|
|
- player.play();
|
|
|
|
+ var _promise = player.play();
|
|
|
|
+ console.log("play() returned promise at 'randomizeCallback': ", _promise);
|
|
|
|
player.currentPlaylistItem = randomItem;
|
|
|
|
playedItems.push(randomItem);
|
|
|
|
|