1.1.1 • Published 9 years ago
lets-build-youtube-module v1.1.1
lets-build-youtube-module
Install
install via npm install lets-build-youtube-module
Options
youtubeIdyoutube id of videoautoplayoption to start playing video as soon as it's loaded; defaultfalseonReadycallback when video is loadedonPausecallback function when video is pausedonPlaycallback function when video resumes playing after pauseonEndedcallback function when video ends
Events
startVideostart the videoplayPauseVideopause video if playing; play video if pausedstopVideostop the videogetVideoStateget a numeral value indicating the video state:-1unstarted;0ended;1playing;2paused;3buffering;5video cued
Example
HTML
<div id="ytloader-wduZHtRbSkY"></div>Javascript
This will load a video into an iframe and insert it into the DOM in place of an element with id="youtube-wduZHtRbSkY"
var options = {
youtubeId: 'wduZHtRbSkY',
onReady: function() {
console.log("The video is loaded");
}
}
var player = new YTLoader.embed(options);
//assuming JQuery, bind events like so
$('.a-player-button').click(player.playPause);TODO
- include options to set Iframe params, e.g., showing video player controls