2020-10-01 12:36:36 +00:00
|
|
|
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">
|
2020-09-28 12:23:06 +00:00
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/plyr/dist/plyr.css"/>
|
2020-10-01 12:36:36 +00:00
|
|
|
<video id="player" playsinline controls
|
|
|
|
data-plyr-config='{"controls": ["play-large", "play", "progress", "current-time", "settings", "fullscreen"] }'>
|
2020-09-28 12:23:06 +00:00
|
|
|
<source id="src" />
|
|
|
|
</video>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/plyr"></script>
|
2020-10-01 06:07:00 +00:00
|
|
|
<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.js"></script>
|
2020-09-28 12:23:06 +00:00
|
|
|
<script>
|
2020-10-01 12:36:36 +00:00
|
|
|
const source = location.search.substring(3);
|
|
|
|
document.getElementById("src").src = source;
|
2020-10-01 06:07:00 +00:00
|
|
|
const video = document.querySelector("video");
|
2020-10-01 12:36:36 +00:00
|
|
|
let i = source.indexOf(".m3u8");
|
|
|
|
if(i>0 &&
|
|
|
|
(source.length <= (i+5) || '?'===source.charAt(i+5)))
|
|
|
|
{
|
2020-10-01 06:07:00 +00:00
|
|
|
const hls = new Hls();
|
|
|
|
hls.loadSource(source);
|
2020-10-01 12:36:36 +00:00
|
|
|
const defaultOptions = {};
|
2020-10-01 06:07:00 +00:00
|
|
|
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
|
|
|
|
const availableQualities = hls.levels.map((l) => l.height);
|
|
|
|
defaultOptions.quality = {
|
|
|
|
default: availableQualities[0],
|
|
|
|
options: availableQualities,
|
|
|
|
forced: true,
|
|
|
|
onChange: (e) => updateQuality(e),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize new Plyr player with quality options
|
|
|
|
const player = new Plyr(video, defaultOptions);
|
|
|
|
});
|
|
|
|
hls.attachMedia(video);
|
|
|
|
window.hls = hls;
|
|
|
|
} else {
|
2020-10-01 12:36:36 +00:00
|
|
|
const player = new Plyr(video);
|
2020-10-01 06:07:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateQuality(newQuality) {
|
|
|
|
window.hls.levels.forEach((level, levelIndex) => {
|
|
|
|
if (level.height === newQuality) {
|
|
|
|
console.log("Found quality match with " + newQuality);
|
|
|
|
window.hls.currentLevel = levelIndex;
|
|
|
|
}
|
|
|
|
});
|
2020-09-28 12:23:06 +00:00
|
|
|
}
|
|
|
|
</script>
|