# hls.js
hls.js is a JavaScript library which implements an HTTP Live Streaming client.
It relies on HTML5 video and MediaSource Extensions for playback.
It works by transmuxing MPEG-2 Transport Stream into ISO BMFF (MP4) fragments. This transmuxing could be performed asynchronously using Web Worker if available in the browser.
hls.js does not need any player, it works directly on top of a standard HTML<video>element.
hls.js is written in ECMAScript6, and transpiled in ECMAScript5 using Babel.
Public demo : http://dailymotion.github.io/hls.js/demo
Private demo accessible from Dailymotion network: http://gdupontavice.dev.dailymotion.com/hls.js/demo/index.html
hls.js is (being) integrated in the following players:
It might also be integrated in the following players if you push for it !
No external JS libs are needed. Prepackaged build is included in the [dist] (dist) folder:
If you want to bundle the application yourself, use node
npm install hls.js
Either directly include dist/hls.js or dist/hls.min.js
Or type
npm install --save hls.js
hls.js is compatible with browsers supporting MSE with ‘video/MP4’ inputs. As of today, it is supported on:
All HLS resources must be delivered with CORS headers permitting GET requests.
#EXTM3U#EXTINF#EXT-X-STREAM-INF (adaptive streaming)#EXT-X-ENDLIST (Live playlist)#EXT-X-MEDIA-SEQUENCE#EXT-X-TARGETDURATION#EXT-X-DISCONTINUITY#EXT-X-BYTERANGE#EXT-X-KEY (https://tools.ietf.org/html/draft-pantos-http-live-streaming-08#section-3.4.4)#EXT-X-PROGRAM-DATE-TIME (https://tools.ietf.org/html/draft-pantos-http-live-streaming-18#section-4.3.2.6)EXT-X-START:TIME-OFFSET=x (https://tools.ietf.org/html/draft-pantos-http-live-streaming-18#section-4.3.5.2)<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script>
<video id="video"></video>
<script>
if(Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource('http://www.streambox.fr/playlists/test_001/stream.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.play();
});
}
</script>
Video is controlled through HTML <video> element.
HTMLVideoElement control and events could be used seamlessly.
hls.js can be configured and controlled easily, click here for details.
hls.js is released under Apache 2.0 License
Pull requests are welcome. Here is a quick guide on how to start.
sh
git clone https://github.com/dailymotion/hls.js.git
# setup dev environement
cd hls.js
npm install
# build dist/hls.js, watch file change for rebuild and launch demo page
npm run dev
# lint
npm run lint
.editorconfig file.dist/hls.js file in your PR. We’ll take care of generating an updated build right before releasing a new tagged version.Click here for details.