A simple HTML5/YouTube Video Element with a unified interface
npm i video-element
The constructor can be used with or without the "new" keyword
var Video = require;var myVid = new Video;
var Video = require;Video
The options parameter accepts these properties:
type: 'youtube', // defaults to html5url: 'videos/myVideo.mp4', // or just the youtube ID
You can find more information about the supported params in their values in https://developers.google.com/youtube/player_parameters.
The callback parameter returns an error as the first paramenter, and the player object as the second. If there is an error, the player will be undefined, if not, the error will be undefined.
The player implements signals for its event interface, these are the available signals:
onInit: player has been createdonReady: player is ready to playonPlay: player has started playingonPause: player is pausedonEnd: player has reached the end of the videoonProgress: dispatched on a timer
Plays the video
Pauses the video
Adds the player to a dom element, if a string, it will assume its an ID and use document.getElementByID.
Destroys the video and removes it from the dom
MIT, see LICENSE.md for details.