From a7c1f13f99e78f2d464631dce1887f65b8dac891 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Thu, 10 Jun 2021 09:57:09 +0200 Subject: [PATCH] Attempt for ios --- index.html | 56 +++++++++++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/index.html b/index.html index 742bdb3..7c051a4 100644 --- a/index.html +++ b/index.html @@ -38,41 +38,33 @@ app.ports.initVideo.subscribe(function(arg) { const video = document.getElementById('video'); - const hls = new Hls(); - hls.loadSource(arg); + if (Hls.isSupported()) { + const hls = new Hls(); + hls.loadSource(arg); - hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) { - // Transform available levels into an array of integers (height values). - const availableQualities = hls.levels.map((l) => l.height); - availableQualities.unshift(0); - app.ports.nowHasQualities.send(availableQualities); - }); + hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) { + // Transform available levels into an array of integers (height values). + const availableQualities = hls.levels.map((l) => l.height); + availableQualities.unshift(0); + app.ports.nowHasQualities.send(availableQualities); + }); - hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) { - // var span = document.querySelector(".plyr__menu__container [data-plyr='quality'][value='0'] span"); - // if (hls.autoLevelEnabled) { - // span.innerHTML = "Auto (" + hls.levels[data.level].height + "p)"; - // } else { - // span.innerHTML = "Auto"; - // } - // var x = document.querySelectorAll(".plyr__menu__container [data-plyr='settings'] span")[3]; - // if (x.innerHTML.startsWith("Auto") || x.innerHTML === "0p") { - // x.innerHTML = span.innerHTML; - // } - }) + hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) { + // var span = document.querySelector(".plyr__menu__container [data-plyr='quality'][value='0'] span"); + // if (hls.autoLevelEnabled) { + // span.innerHTML = "Auto (" + hls.levels[data.level].height + "p)"; + // } else { + // span.innerHTML = "Auto"; + // } + // var x = document.querySelectorAll(".plyr__menu__container [data-plyr='settings'] span")[3]; + // if (x.innerHTML.startsWith("Auto") || x.innerHTML === "0p") { + // x.innerHTML = span.innerHTML; + // } + }) - hls.attachMedia(video); - - function updateQuality(newQuality) { - if (newQuality === 0) { - hls.currentLevel = -1; - } else { - hls.levels.forEach((level, levelIndex) => { - if (level.height === newQuality) { - hls.currentLevel = levelIndex; - } - }); - } + hls.attachMedia(video); + } else if (video.canPlayType('application/vnd.apple.mpegurl')) { + video.src = arg; } });