From 2977972274e6255055b8f932f9a2c0a5eeaf8ecc Mon Sep 17 00:00:00 2001 From: Zed Date: Mon, 18 Nov 2019 18:26:48 +0100 Subject: [PATCH] Fix video playback on iOS --- public/js/hlsPlayback.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/public/js/hlsPlayback.js b/public/js/hlsPlayback.js index c2e4eec..84b6616 100644 --- a/public/js/hlsPlayback.js +++ b/public/js/hlsPlayback.js @@ -1,15 +1,22 @@ function playVideo(overlay) { const video = overlay.parentElement.querySelector('video'); + const url = video.getAttribute("data-url"); video.setAttribute("controls", ""); overlay.style.display = "none"; - const url = video.getAttribute("data-url"); - var hls = new Hls({autoStartLoad: false}); - hls.loadSource(url); - hls.attachMedia(video); - hls.on(Hls.Events.MANIFEST_PARSED, function () { - hls.loadLevel = hls.levels.length - 1; - hls.startLoad(); - video.play(); - }); + if (Hls.isSupported()) { + var hls = new Hls({autoStartLoad: false}); + hls.loadSource(url); + hls.attachMedia(video); + hls.on(Hls.Events.MANIFEST_PARSED, function () { + hls.loadLevel = hls.levels.length - 1; + hls.startLoad(); + video.play(); + }); + } else if (video.canPlayType('application/vnd.apple.mpegurl')) { + video.src = url; + video.addEventListened('canplay', function() { + video.play(); + }); + } }