Skip to content
hls.js Source Handler for video.js 5
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Add deploy checkpoint Aug 31, 2018
ci removes not used commented out leftovers Aug 14, 2018
example Revert sample May 10, 2019
.babelrc Use Webpack toolkit Mar 6, 2018
.editorconfig adds .editorconfig Mar 28, 2018
.eslintrc adds pre init hooks Mar 29, 2018
.gitignore udpates .gitignore Aug 14, 2018 [no-deploy][no-sync] Updating CHANGELOG and package.json for '1.0.12'… May 10, 2019 add mit license Jul 5, 2016 Update docs Feb 19, 2019
package.json [no-deploy][no-sync] Updating CHANGELOG and package.json for '1.0.12'… May 10, 2019

video.js HLS Source Handler

Adds HLS playback support to video.js 5.0+ using hls.js library.


A pre-built version is available:

Manually build the plugin

Clone the repository. Install the dependcies npm install. Use npm run build to build the dist scripts.



Include video.js and videojs-hlsjs-plugin.js in your page:

    <link href="" rel="stylesheet">
    <script src=""></script>

    <script src="videojs-hlsjs-plugin.js"></script>
    <video id=example-video width=600 height=300 class="video-js vjs-default-skin" controls>
        <source src="" type="application/x-mpegURL">
        var options = {
            html5: {
                hlsjsConfig: {
                  // Put your hls.js config here

        // setup beforeinitialize hook
        videojs.Html5Hlsjs.addHook('beforeinitialize', (videojsPlayer, hlsjsInstance) => {
            // here you can interact with hls.js instance and/or video.js playback is initialized

        var player = videojs('example-video', options);

There are several ways of getting video.js files, you can read about them in official documentation and choose the one that match your needs best.


const videojs = require('video.js');
const videojsHlsjsSourceHandler = require('videojs-hlsjs-plugin');


Passing configuration options to hls.js

Define hlsjsConfig property in html5 field of video.js options object and pass it as second param to videojs constructor. List of available hls.js options is here:

    var options = {
        html5: {
            hlsjsConfig: {
                debug: true
    var player = videojs('example-video', options);

Initialization Hook

Sometimes you may need to extend hls.js, or have access to the hls.js before playback starts. For these cases, you can register a function to the beforeinitialize hook, which will be called right after hls.js instance is created.

Your function should have two parameters:

  1. The video.js Player instance
  2. The hls.js instance
var callback = function(videojsPlayer, hlsjs) {
  // do something

videojs.Html5Hlsjs.addHook('beforeinitialize', callback);

You can remove the hook by:

videojs.Html5Hlsjs.removeHook('beforeinitialize', callback);

Caption configurations

In hls.js if caption positioning information is not provided in WebVTT it will be hard coded into a certain location on-screen. We provide a custom option to allow users to override property of the caption's cues:

You can add as many beforeinitialize hooks as necessary by calling videojs.Html5Hlsjs.addHook several times.

You can’t perform that action at this time.