3.0.4 • Published 4 years ago
@superherocheesecake/youtube-manager v3.0.4
YoutubeManager
Small helper that will load the Youtube script the moment you need it. Your application will initially load faster, because you don't have to wait for this third party API to finish loading.
NPM installation
npm i --save @superherocheesecake/youtube-managerLoad
import YoutubeManager from '@superherocheesecake/youtube-manager';
const youtubeManager = new YoutubeManager();
youtubeManager.addEventListenerOnce('ready', this._youtubeReadyHandler);
youtubeManager.load();Youtube API Usage
_youtubeReadyHandler: function() {
this.player = new YT.Player('[#ID]', {
videoId: [YOUTUBE ID],
playerVars: {autoplay: 1, showinfo: 0},
width: [WIDTH],
height: [HEIGHT],
});
this.player.addEventListener('onStateChange', this._onStateChangeHandler);
},
_onStateChangeHandler: function(e) {
switch(e.data) {
case YT.PlayerState.ENDED:
console.log('ended');
break;
case YT.PlayerState.PLAYING:
console.log('playing');
break;
case YT.PlayerState.PAUSED:
console.log('paused');
break;
case YT.PlayerState.BUFFERING:
console.log('buffering');
break;
case YT.PlayerState.CUED:
console.log('cued');
break;
}
}3.0.4
4 years ago
3.0.4-canary.4
5 years ago
3.0.4-canary.3
5 years ago
3.0.3
6 years ago
3.0.2
6 years ago
3.0.1
6 years ago
3.0.0
6 years ago