Attempt for ios
This commit is contained in:
parent
c43e989459
commit
a7c1f13f99
56
index.html
56
index.html
|
@ -38,41 +38,33 @@
|
||||||
|
|
||||||
app.ports.initVideo.subscribe(function(arg) {
|
app.ports.initVideo.subscribe(function(arg) {
|
||||||
const video = document.getElementById('video');
|
const video = document.getElementById('video');
|
||||||
const hls = new Hls();
|
if (Hls.isSupported()) {
|
||||||
hls.loadSource(arg);
|
const hls = new Hls();
|
||||||
|
hls.loadSource(arg);
|
||||||
|
|
||||||
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
|
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
|
||||||
// Transform available levels into an array of integers (height values).
|
// Transform available levels into an array of integers (height values).
|
||||||
const availableQualities = hls.levels.map((l) => l.height);
|
const availableQualities = hls.levels.map((l) => l.height);
|
||||||
availableQualities.unshift(0);
|
availableQualities.unshift(0);
|
||||||
app.ports.nowHasQualities.send(availableQualities);
|
app.ports.nowHasQualities.send(availableQualities);
|
||||||
});
|
});
|
||||||
|
|
||||||
hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) {
|
hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) {
|
||||||
// var span = document.querySelector(".plyr__menu__container [data-plyr='quality'][value='0'] span");
|
// var span = document.querySelector(".plyr__menu__container [data-plyr='quality'][value='0'] span");
|
||||||
// if (hls.autoLevelEnabled) {
|
// if (hls.autoLevelEnabled) {
|
||||||
// span.innerHTML = "Auto (" + hls.levels[data.level].height + "p)";
|
// span.innerHTML = "Auto (" + hls.levels[data.level].height + "p)";
|
||||||
// } else {
|
// } else {
|
||||||
// span.innerHTML = "Auto";
|
// span.innerHTML = "Auto";
|
||||||
// }
|
// }
|
||||||
// var x = document.querySelectorAll(".plyr__menu__container [data-plyr='settings'] span")[3];
|
// var x = document.querySelectorAll(".plyr__menu__container [data-plyr='settings'] span")[3];
|
||||||
// if (x.innerHTML.startsWith("Auto") || x.innerHTML === "0p") {
|
// if (x.innerHTML.startsWith("Auto") || x.innerHTML === "0p") {
|
||||||
// x.innerHTML = span.innerHTML;
|
// x.innerHTML = span.innerHTML;
|
||||||
// }
|
// }
|
||||||
})
|
})
|
||||||
|
|
||||||
hls.attachMedia(video);
|
hls.attachMedia(video);
|
||||||
|
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||||
function updateQuality(newQuality) {
|
video.src = arg;
|
||||||
if (newQuality === 0) {
|
|
||||||
hls.currentLevel = -1;
|
|
||||||
} else {
|
|
||||||
hls.levels.forEach((level, levelIndex) => {
|
|
||||||
if (level.height === newQuality) {
|
|
||||||
hls.currentLevel = levelIndex;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue