109k views
3 votes
What is and How does HLS.js work?

1 Answer

3 votes

Final answer:

HLS.js is a JavaScript library used to playback HTTP Live Streaming (HLS) on platforms where it isn't natively supported. It operates by fetching the HLS playlist file, downloading the segments, and feeding these to the video tag with the Media Source Extensions API.

Step-by-step explanation:

HLS.js is a Javascript library that works primarily to play HLS (HTTP Live Streaming) on platforms where it is not natively supported. HLS, developed by Apple, is a media-streaming protocol that splits the stream into a series of small HTTP-based file downloads. Each download loading one short chunk of an overall potentially unbounded transport stream.

As a library, HLS.js operates as an intermediary between HTTP content and the video element where the content will be displayed. It is utilized when the media that the user wants to load is not directly supported by their browser, such as when trying to play HLS on browsers like Chrome, Firefox, or Edge.

The work process of HLS.js is simple. First, it fetches the HLS playlist file, then it starts downloading the segments as mentioned in the playlist. After that, it uses the Media Source Extensions (MSE) API to feed the video tag with the media segments it loaded.

Learn more about HLS.js

User WhiteHorse
by
7.6k points