Difference between revisions of "Widget:MerlinVideoPlayer"

From Coder Merlin
(Created page with "<video id="video"></video> <script> if (Hls.isSupported()) { var video = document.getElementById('video'); var hls = new Hls(); // bind them together hls.att...")
 
Line 1: Line 1:
<video id="video"></video>
<video id="video"></video>
<script>
<script>
   if (Hls.isSupported()) {
   window.addEventListener('load', (event) => {
    var video = document.getElementById('video');
    if (Hls.isSupported()) {
    var hls = new Hls();
      var video = document.getElementById('video');
    // bind them together
      var hls = new Hls();
    hls.attachMedia(video);
      // bind them together
    hls.on(Hls.Events.MEDIA_ATTACHED, function () {
      hls.attachMedia(video);
      console.log('video and hls.js are now bound together !');
      hls.on(Hls.Events.MEDIA_ATTACHED, function () {
      hls.loadSource('http://my.streamURL.com/playlist.m3u8');
        console.log('video and hls.js are now bound together !');
      hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
        hls.loadSource('http://my.streamURL.com/playlist.m3u8');
        console.log(
        hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
          'manifest loaded, found ' + data.levels.length + ' quality level'
          console.log(
         );
            'manifest loaded, found ' + data.levels.length + ' quality level'
          );
         });
       });
       });
     });
     }
   }
   }
</script>
</script>

Revision as of 12:02, 23 November 2021

<video id="video"></video> <script>

 window.addEventListener('load', (event) => {
   if (Hls.isSupported()) {
     var video = document.getElementById('video');
     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('http://my.streamURL.com/playlist.m3u8');
       hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
         console.log(
           'manifest loaded, found ' + data.levels.length + ' quality level'
         );
       });
     });
   }
 }

</script>