fixed a bug on the web player
This commit is contained in:
@@ -410,11 +410,26 @@ const AnimePlayer = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initVideoPlayer(url, type, subtitles = []) {
|
function initVideoPlayer(url, type, subtitles = []) {
|
||||||
const video = els.video;
|
if (plyrInstance) {
|
||||||
Array.from(video.querySelectorAll('track')).forEach(t => t.remove());
|
plyrInstance.destroy();
|
||||||
|
plyrInstance = null;
|
||||||
|
}
|
||||||
|
if (hlsInstance) {
|
||||||
|
hlsInstance.destroy();
|
||||||
|
hlsInstance = null;
|
||||||
|
}
|
||||||
|
|
||||||
const newVideo = video.cloneNode(true);
|
const container = document.querySelector('.video-frame');
|
||||||
video.parentNode.replaceChild(newVideo, video);
|
|
||||||
|
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 = newVideo;
|
||||||
|
|
||||||
els.video.addEventListener("play", () => {
|
els.video.addEventListener("play", () => {
|
||||||
|
|||||||
@@ -354,8 +354,27 @@ const AnimePlayer = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initVideoPlayer(url, type, subtitles = []) {
|
function initVideoPlayer(url, type, subtitles = []) {
|
||||||
const video = els.video;
|
if (plyrInstance) {
|
||||||
Array.from(video.querySelectorAll('track')).forEach(t => t.remove());
|
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'))) {
|
if (Hls.isSupported() && (type === 'm3u8' || url.includes('.m3u8'))) {
|
||||||
console.log("Using HLS.js");
|
console.log("Using HLS.js");
|
||||||
|
|||||||
Reference in New Issue
Block a user