Giter Club home page Giter Club logo

videojs-playlist's Introduction

Video.js playlist

A video-js plugin to play multiple videos or multiple audio tracks . It is one of a growing number of plugins for the awesome video-js library

Rationale: The main goal in developing this plugin is to play audio files. Playing audio is possible with video-js either by swapping the <video> for an <audio> tag or by simply feeding audio tracks to the <video> tag. Both approaches have their pluses and minuses which are documented here in video.js's issues.

DEMO

http://tim-peterson.github.io/videojs-playlist/

Using the Plugin

The plugin automatically registers itself when you include video.playlist.js in your page:

<script src='videojs.playlist.js'></script>

You probably want to include the default stylesheet, too. It provides some basic styling to indicate what track is currently playing:

<link href="videojs.playlist.css" rel="stylesheet">

The Playlist plugin has one required id and class names in the HTML

id="XXX-vjs-playlist" //playlist wrapper ID that is specific to the instantiated videojs object ID, e.g., id="audio-playlist-vjs-playlist". This is necessary such that multiple videojs players can exist on the same page.

class="vjs-track" // tracks className

The Playlist plugin currently takes four options, mediaType, continuous, and setTrack:

var myPlaylist=myPlayerPlaylist.playlist({

      "continuous": true,
      "setTrack": 2
    });

mediaType (string) specifies whether the player should play HTML5 video or audio. If you want <audio> set this option to "audio". Not including this option is the same as setting it to video.

continuous (bool) specifies whether the playlist should play the next track after the previous one finishes. Setting this to false prevents the continuous playback. Not including this option is the same as setting it to true.

setTrack (int) allows manually setting the initial track that should be played. It's a zero-indexed integer based on the number of tracks in the playlist.

onTrackSelected (function) callback for when a track has been selected. this will be set to to the HTML element that is now the currently selected track.

The playlist object returns several values:

1. myPlaylist.index() //returns the current track (0-indexed)
2. myPlaylist.trackCount //indicates the total number of tracks
3. myPlaylist.tracks //returns javascript object of all tracks document.querySelectorAll("#"+this.player.id+'.vjs-track')
4. myPlaylist.prev() //manually triggers the previous track and stays on the 1st track if at the last track
5. myPlaylist.next() //manually triggers the next track and returns to the 1st track if at the last track

Future options being considered include: 1) a shuffle button to shuffle tracks and 2) rendering the playlist using JS rather than as it is currently done with HTML. The intent is to allow a playlist {} object to be fed in. I'd be happy for your feedback, [email protected].

videojs-playlist's People

Contributors

tim-peterson avatar gaqzi avatar da1nonly avatar

Watchers

Yu DieGui avatar James Cloos avatar

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.