video-element
A simple HTML5/YouTube Video Element with a unified interface
Installation
npm i video-element
Usage
The constructor can be used with or without the "new" keyword
var Video = require;var myVid = new Video;
OR
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.
Signals
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
player.play()
Plays the video
player.pause()
Pauses the video
player.appendTo(dom)
Adds the player to a dom element, if a string, it will assume its an ID and use document.getElementByID.
player.destroy()
Destroys the video and removes it from the dom
License
MIT, see LICENSE.md for details.