Free HLS Player HTML5

Posted Under: HTML5, JavaScript, Programming, Tutorials, Video on Sep 8, 2022
Free HLS Player HTML5
HTTP Live Streaming or HLS Player is a media streaming protocol that deliver content to the users according to their bandwidth availability. The basic building blocks of a HLS streams are M3U8 playlists. You can create multiple files for distribution to the player, which can adaptively change streams to optimize the playback experience. As an HTTP-based technology, no streaming server is required, so all the switching logic resides on the player. HTML5 Video Tag does not support it out of the box, but with the help of a simple javascript library you can turn your humble HTML5 Video Tag in to a HLS Player. For that you need HLS.js library and simple invocation code. hls.js uses Media Source Extensions, so it must be available on the browser, good news it that almost all modern browsers supports it. Below is a working code for quick copy paste.

        <meta charset="UTF-8">
        <title>Simple Free HLS Player Example</title>  
        <!-- Include hls.js from a CDN -->
        <script src="https://cdn.tutorialjinni.com/hls.js/1.2.1/hls.min.js"></script>
        <!-- HTML5 Video Tag -->
        <video id="video" 
               width='480px' height='360px' controls autoplay
        <!-- Invocation Script -->
            if (Hls.isSupported()) {
              var video = document.getElementById('video');
              var hls = new Hls();
                alert("Cannot stream HLS, use another video source");