Git Product home page Git Product logo

videojs-contrib-hls.js's Introduction

HLS plugin for video.js using hls.js

Plays HLS with video.js on any platform, even where it's not natively supported, using Dailymotion's hls.js tech.

This bundled plugin is an alternative to the original videojs-contrib-hls and runs directly on top of video.js 5.0+.

Like the original implementation, this plugin implements a source handler for m3u8 files. hls.js is bundled inside and there is no need to include it in addition.

Installation

NPM

To install videojs-contrib-hls.js with npm run

npm install --save videojs-contrib-hls.js

CDN

Get the latest stable version from the CDN

Releases

Download a release of videojs-contrib-hls

Getting Started

Get a copy of videojs-contrib-hls and include it in your page along with video.js:

<video id=player width=600 height=300 class="video-js vjs-default-skin" controls>
  <source src="https://example.com/index.m3u8" type="application/x-mpegURL">
</video>
<script src="video.js"></script>
<script src="videojs-contrib-hlsjs.min.js"></script>
<script>
  var player = videojs('#player');
</script>

in a CommonJS app

var videojs = require('video.js');
require('videojs-contrib-media-sources'); // increase browser support with MSE polyfill
require('videojs-contrib-hls.js'); // auto attaches hlsjs handler

var player = videojs('#player');

Options

hls.js is very configurable, you may pass in an options object to the source handler at player initialization. You can pass in options just like you would for other parts of video.js:

<video id=player width=600 height=300 class="video-js vjs-default-skin" controls>
  <source src="https://example.com/index.m3u8" type="application/x-mpegURL">
</video>
<script src="video.js"></script>
<script src="videojs-contrib-hlsjs.min.js"></script>
<script>
    var player = videojs('video', {
        autoplay: true,
        html5: {
            hlsjsConfig: {
                debug: true
            }
        }
    });
</script>

Advanced Usage

Listening to hls.js events

events are passed to the tech and can be subscribed to

   var player = videojs('video');
   player.tech_.on(Hls.Events.MANIFEST_LOADED, function (e) {
       // do something
   })

full list of hls.js events can be found here

NOTE hls.js global is exposed to window.Hls when the module is loaded

Custom hls.js configuration

DO NOT USE THIS REF UNLESS YOU KNOW WHAT YOU ARE DOING

the hls.js instance is exposed on the sourceHandler instance

   var player = videojs('video');
   // player.tech_.sourceHandler_.hls is the underlying Hls instance
   player.tech_.sourceHandler_.hls.currentLevel = -1

videojs-contrib-hls.js's People

Contributors

benvirus avatar boushley avatar ganigeorgiev avatar jgubman avatar kprigel avatar mrbar42 avatar shacharz avatar tmm1 avatar user890104 avatar whadar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

videojs-contrib-hls.js's Issues

Update HLS.js?

The most recent stable version of HLS.js is v0.12.1

This plugin is using v0.8.9

Why the name "videojs-contrib-hls.js"?

I was wondering why this project is called "videojs-contrib-hls.js", it doesn't seem to be related to the videojs-contrib-hls plugin and "contrib" is used to signify projects offered by the org (see grunt-contrib-* for example)

Uncaught TypeError: Cannot read property 'code' of null

I am getting the following error from the mediaError eventListener

Uncaught TypeError: Cannot read property 'code' of null
    at HTMLVideoElement.<anonymous>

Which comes from:

// listen to error events coming from the video tag
el.addEventListener('error', function(e) {
  var mediaError = e.currentTarget.error; // => null

  if (mediaError.code === mediaError.MEDIA_ERR_DECODE) {
    videoTagErrorHandler();
  } else {
    console.error('Error loading media: File could not be played');
  }
});

Any idea why this is occurring?

videojs captions button does not appear

Captions button does not appear when viewing a live stream with captions. Hls.js is processing captions and I can manually display by calling:

videojs.textTracks[0].mode = 'showing'

Can you point me to a brief example showing how to enable the captions button? Do I need to wire it up to call mode = 'showing' and mode = 'hidden' ?

Thank you!

Does not support videojs-contrib-quality-levels

I just made the switch from @videojs/http-streaming to videojs-contrib-hls.js to try and fix playback of several different videos that were not working properly in @videojs/http-streaming. However my player has a quality selector button which displays the various renditions available (1080p, 720p, 540p, etc) - and his button stopped functioning with HLS.js

If HLS.js provides events for the detection of new renditions or hooks for determining which rendition is currently playing or limiting which renditions are allowed, then adding support for videojs-contrib-quality-levels shouldn't be impossible. If HLS.js does not provide this and instead black-boxes all of the playback details, then a pull request on HLS.js may be necessary.

gulp/browserify: Cannot find module 'videojs-contrib-hls.js'

Error when creating a bundle using gulp and browserify:

Error: Cannot find module 'videojs-contrib-hls.js'

Any clues on what may be happening here? I create a bundle of all 3rd party packages using a line like this in gulp.js:

extLibPackageNames.forEach(function (name) { browserify.require(name); });

All other packages work, including react, videojs, videojs-contrib-media-sources, hls.js, etc. The only problem is videojs-contrib-hls.js

  1. I have removed and re-installed the package.
  2. Confirmed node_path
  3. Cleared node-cache

Any suggestions?

Thank you!

Dependency on other videojs-contrib-hls project

Why does this project depend on and include the entire bundle for the videojs/videojs-contrib-hls project?

Right now the package.json depends on the other project.
The Gulpfile is bundling the entire other library.
In addition the example separated.html file this other library is included.

However if I remove that dependency from separated.html example the library continues to work. Does this library actually need a dependency on videojs/videojs-contrib-hls? If so, what for?

Android webview in fullscreen black screen?

Hi, I'm using video.js to play live HLS stream.

This repo is stable than the video.js official video-contrib-hls in most situations. Thanks for your works!

But I encountered that when I play live HLS stream in android webview and open fullscreen, it has no video but only audio.

Anyone has similar situations?

PS: I use 3.0.3 now

CEA 608/708 captions into video.js on Chrome/FireFox

Hi, we are using hls.js+videojs-contrib-hls.js+video.js to playback live HLS content with embedded CEA 608/708 captions.

On Safari (using hls.js+videojs-contrib-hls.js via MSE, not native HLS playback), the CC button correctly appears in the video.js player control bar when the material contains CEA 608/708 captions; selecting "english" from the popup results in the proper rendering of captions.

On FireFox and Chrome, the CC button never appears.

If I try playing the source with the hls.js demo player in FireFox and Chrome (using hls.js directly on top of HTML5 video tag), the CC button shows up, and the captions render, suggesting the video.js part of this is working.

If I understand correctly, hls.js translates CEA 608/708 captions into text tracks which are then rendered by video.js and/or the HTML5 video control.

Is there additional glue code required in the videojs-control-hls.js bridge to make video.js aware of tracks in Chrome/FireFox?

I'm kind of surprised this works in Safari; it suggests that perhaps the HTML5 video element in safari is capable of handling text tracks wherein the video element in Chrome/FireFox isn't?

thoughts?

Thank you!
Ty

No audio in Chrome (Mac)

Here are two versions of the same page, one using peer5/videojs-contrib-hls, which has no audio during playback in Chrome:
https://statusrecap.com/test.html

And the other using only videojs-contrib-hls, which does have audio during playback:
https://statusrecap.com/

I am using your excellent library on another site currently under development that uses VideoJS 5 source elements, which will only work using the peer5 version of videojs-contrib-hls, but unfortunately it produces the same no audio result.

Retry the video in case of Network error

Hi,

How can i retry for the video when I gets network error. I have tried to get error using

this.player.on('error',(e)={ 
 console.log(e)
})

But this one doesn't catch any error even though I am getting 404 error in console.

Any suggestion for this one

Thanks,

Get 'hls' reference

Thanks for your working first.

The problem is How can i get a reference to hls?
I need to handle errors outside the videojs-contrib-hlsjs.js.

how to correctly setup with videojs

I am trying to setup/register videojs-contrib-hls with videojs like below but its not working, it says
a is undefined

videojs.registerComponent('Hls', require('videojs-contrib-hls'));

What is the correct way to setup videojs-contrib-hls with videojs using requirejs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.