Difference between revisions of "Widget:MerlinVideoPlayer"
From Coder Merlin
Line 1: | Line 1: | ||
<video id=" | <video id="<!--{$videoID}-->"></video> | ||
<script> | <script> | ||
window.addEventListener('load', (event) => { | window.addEventListener('load', (event) => { | ||
if (Hls.isSupported()) { | if (Hls.isSupported()) { | ||
var video = document.getElementById(' | var video = document.getElementById('<!--{$videoID}-->'); | ||
var hls = new Hls(); | var hls = new Hls(); | ||
// bind them together | // bind them together | ||
Line 9: | Line 9: | ||
hls.on(Hls.Events.MEDIA_ATTACHED, function () { | hls.on(Hls.Events.MEDIA_ATTACHED, function () { | ||
console.log('video and hls.js are now bound together !'); | console.log('video and hls.js are now bound together !'); | ||
hls.loadSource('https://stream.mux.com/ | hls.loadSource('https://stream.mux.com/<!--{$videoID}-->.m3u8'); | ||
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) { | hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) { | ||
console.log( | console.log('manifest loaded, found ' + data.levels.length + ' quality level'); | ||
}); | }); | ||
}); | }); |
Revision as of 12:52, 23 November 2021
<video id=""></video> <script>
window.addEventListener('load', (event) => { if (Hls.isSupported()) { var video = document.getElementById(); var hls = new Hls(); // bind them together hls.attachMedia(video); hls.on(Hls.Events.MEDIA_ATTACHED, function () { console.log('video and hls.js are now bound together !'); hls.loadSource('https://stream.mux.com/.m3u8'); hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) { console.log('manifest loaded, found ' + data.levels.length + ' quality level'); }); }); } });
</script>