Started working on implementing official YT iframe-embed API

This commit is contained in:
rainbow napkin 2025-05-07 08:17:38 -04:00
parent 047c368b70
commit 1344756449
3 changed files with 69 additions and 2 deletions

View file

@ -303,4 +303,32 @@ class rawFileHandler extends rawFileBase{
//Return current timestamp
return this.video.currentTime;
}
}
class youtubeEmbedHandler extends mediaHandler{
constructor(client, player, media){
//Call derived constructor
super(client, player, media, 'ytEmbed');
}
buildPlayer(){
//If the embed API has loaded
if(this.client.ytEmbedAPILoaded){
//Create a new youtube player using the official YT iframe-embed api
this.video = new YT.Player('video', {
//Inject video id
videoID: media.id,
//Set up event listeners (NGL kinda nice of google to do it this way...)
events: {
'onReady': this.embedPlayer.bind(this)
}
});
}
//Call derived function
super.buildPlayer();
}
embedPlayer(){
}
}