Fix video playback on iOS

This commit is contained in:
Zed 2019-11-18 18:26:48 +01:00
parent 06945f433b
commit 2977972274

View file

@ -1,15 +1,22 @@
function playVideo(overlay) { function playVideo(overlay) {
const video = overlay.parentElement.querySelector('video'); const video = overlay.parentElement.querySelector('video');
const url = video.getAttribute("data-url");
video.setAttribute("controls", ""); video.setAttribute("controls", "");
overlay.style.display = "none"; overlay.style.display = "none";
const url = video.getAttribute("data-url"); if (Hls.isSupported()) {
var hls = new Hls({autoStartLoad: false}); var hls = new Hls({autoStartLoad: false});
hls.loadSource(url); hls.loadSource(url);
hls.attachMedia(video); hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function () { hls.on(Hls.Events.MANIFEST_PARSED, function () {
hls.loadLevel = hls.levels.length - 1; hls.loadLevel = hls.levels.length - 1;
hls.startLoad(); hls.startLoad();
video.play(); video.play();
}); });
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = url;
video.addEventListened('canplay', function() {
video.play();
});
}
} }