diff --git a/desktop/src/scripts/anime/player.js b/desktop/src/scripts/anime/player.js index 20b17ec..9b34956 100644 --- a/desktop/src/scripts/anime/player.js +++ b/desktop/src/scripts/anime/player.js @@ -410,11 +410,26 @@ const AnimePlayer = (function() { } function initVideoPlayer(url, type, subtitles = []) { - const video = els.video; - Array.from(video.querySelectorAll('track')).forEach(t => t.remove()); + if (plyrInstance) { + plyrInstance.destroy(); + plyrInstance = null; + } + if (hlsInstance) { + hlsInstance.destroy(); + hlsInstance = null; + } - const newVideo = video.cloneNode(true); - video.parentNode.replaceChild(newVideo, video); + const container = document.querySelector('.video-frame'); + + container.innerHTML = ''; + + const newVideo = document.createElement('video'); + newVideo.id = 'player'; + newVideo.controls = true; + newVideo.crossOrigin = 'anonymous'; + newVideo.playsInline = true; + + container.appendChild(newVideo); els.video = newVideo; els.video.addEventListener("play", () => { diff --git a/docker/src/scripts/anime/player.js b/docker/src/scripts/anime/player.js index 20126a0..bed170d 100644 --- a/docker/src/scripts/anime/player.js +++ b/docker/src/scripts/anime/player.js @@ -354,8 +354,27 @@ const AnimePlayer = (function() { } function initVideoPlayer(url, type, subtitles = []) { - const video = els.video; - Array.from(video.querySelectorAll('track')).forEach(t => t.remove()); + if (plyrInstance) { + plyrInstance.destroy(); + plyrInstance = null; + } + if (hlsInstance) { + hlsInstance.destroy(); + hlsInstance = null; + } + + const container = document.querySelector('.video-frame'); + + container.innerHTML = ''; + + const newVideo = document.createElement('video'); + newVideo.id = 'player'; + newVideo.controls = true; + newVideo.crossOrigin = 'anonymous'; + newVideo.playsInline = true; + + container.appendChild(newVideo); + els.video = newVideo; if (Hls.isSupported() && (type === 'm3u8' || url.includes('.m3u8'))) { console.log("Using HLS.js");