From bd9217edf8a6f7a0defd84f45a5b140aeff49aa1 Mon Sep 17 00:00:00 2001 From: Ivana Svobodova Date: Sun, 12 May 2024 15:15:24 +0200 Subject: [PATCH] Fix endedCallback to use sources correctly and not to read after last index --- src/playlist/playlist.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/playlist/playlist.js b/src/playlist/playlist.js index 82112fb..2fcc6b5 100644 --- a/src/playlist/playlist.js +++ b/src/playlist/playlist.js @@ -80,12 +80,14 @@ Object.assign(MediaElementPlayer.prototype, { controls.style.zIndex = 5; player.endedCallback = () => { - if (player.currentPlaylistItem < player.listItems.length) { - player.setSrc(player.playlist[++player.currentPlaylistItem]); + if (player.playlist[++player.currentPlaylistItem]) { + player.setSrc(player.playlist[player.currentPlaylistItem].src); player.load(); setTimeout(() => { player.play(); }, 200); + } else { + --player.currentPlaylistItem; } };