|
|
|
@ -48,24 +48,29 @@ const index = `<!DOCTYPE html> |
|
|
|
const create = () => { |
|
|
|
const create = () => { |
|
|
|
const video = document.getElementById('video'); |
|
|
|
const video = document.getElementById('video'); |
|
|
|
|
|
|
|
|
|
|
|
const hls = new Hls({ |
|
|
|
if (video.canPlayType('application/vnd.apple.mpegurl')) { |
|
|
|
progressive: false, |
|
|
|
video.src = 'stream.m3u8'; |
|
|
|
}); |
|
|
|
video.play(); |
|
|
|
|
|
|
|
} else { |
|
|
|
hls.on(Hls.Events.ERROR, (evt, data) => { |
|
|
|
const hls = new Hls({ |
|
|
|
if (data.fatal) { |
|
|
|
progressive: false, |
|
|
|
hls.destroy(); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
hls.on(Hls.Events.ERROR, (evt, data) => { |
|
|
|
create(); |
|
|
|
if (data.fatal) { |
|
|
|
}, 2000); |
|
|
|
hls.destroy(); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
create(); |
|
|
|
|
|
|
|
}, 2000); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
hls.loadSource('stream.m3u8'); |
|
|
|
hls.loadSource('stream.m3u8'); |
|
|
|
hls.attachMedia(video); |
|
|
|
hls.attachMedia(video); |
|
|
|
|
|
|
|
|
|
|
|
video.play(); |
|
|
|
video.play(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
create(); |
|
|
|
create(); |
|
|
|
|
|
|
|
|
|
|
|
|