Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including fw-videojs-playlist with all npm packages installed. Try it out:

var fwVideojsPlaylist = require("fw-videojs-playlist")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

fw-videojs-playlist v4.0.4

Playlist plugin for Video.js

Build Status

Filmweb fork of Brightcove Playlist Plugin for video.js

Installation

Install fw-videojs-playlist via npm (preferred):

$ npm install fw-videojs-playlist

Basic Usage

For full details on how to use the playlist plugin can be found in the API documentation.

var player = videojs('video');

player.playlist([{
  sources: [{
    src: 'http://media.w3.org/2010/05/sintel/trailer.mp4',
    type: 'video/mp4'
  }],
  poster: 'http://media.w3.org/2010/05/sintel/poster.png'
}, {
  sources: [{
    src: 'http://media.w3.org/2010/05/bunny/trailer.mp4',
    type: 'video/mp4'
  }],
  poster: 'http://media.w3.org/2010/05/bunny/poster.png'
}, {
  sources: [{
    src: 'http://vjs.zencdn.net/v/oceans.mp4',
    type: 'video/mp4'
  }],
  poster: 'http://www.videojs.com/img/poster.jpg'
}, {
  sources: [{
    src: 'http://media.w3.org/2010/05/bunny/movie.mp4',
    type: 'video/mp4'
  }],
  poster: 'http://media.w3.org/2010/05/bunny/poster.png'
}, {
  sources: [{
    src: 'http://media.w3.org/2010/05/video/movie_300.mp4',
    type: 'video/mp4'
  }],
  poster: 'http://media.w3.org/2010/05/video/poster.png'
}]);

// Play through the playlist automatically.
player.playlist.autoadvance(0);

Fork changes

playlistautoadvance event

Event fires on autoadvance, but not in other playlist change circumstances.

Custom setSource function

Allows to override default change source behaviour provided by videojs on item change. Function is used between beforeplaylistitem and playlistitem events, and allows you extend or replace the default player.src() method.

player.playlist.customSrcFunction(function(player,item) { 
    /*...*/ 
})

Use case - google IMA plugin:

player.playlist.customSrcFunction(function(player, item){
        if (player.ima && typeof player.ima.setContentWithAdTag === 'function') {
            player.ima.setContentWithAdTag(item.sources, null, true);
            player.ima.requestAds();
        } else {
            player.src(item.sources);
        }
    });

License

Apache-2.0. Copyright (c) Brightcove, Inc.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free