Started work on HLS livestreaming

This commit is contained in:
rainbow napkin 2025-05-11 08:19:30 -04:00
parent 93265b7890
commit c6de68b474
6 changed files with 193 additions and 29 deletions

View file

@ -158,8 +158,13 @@ class rawFileBase extends mediaHandler{
buildPlayer(){
//Create player
this.video = document.createElement('video');
//Enable controls
this.video.controls = true;
//Append it to page
this.player.videoContainer.appendChild(this.video);
//Run derived method
super.buildPlayer();
}
@ -488,4 +493,43 @@ class youtubeEmbedHandler extends mediaHandler{
this.iframe.style.pointerEvents = (lock ? "none" : "");
}
}
}
class hlsBase extends rawFileBase{
constructor(client, player, media, type){
//Call derived constructor
super(client, player, media, type);
//Create property to hold HLS object
this.hls = null;
}
buildPlayer(){
//Call derived player
super.buildPlayer();
//Instantiate HLS object
this.hls = new Hls();
//Load HLS Stream
this.hls.loadSource(this.nowPlaying.url);
//Attatch hls object to video element
this.hls.attachMedia(this.video);
//Bind onMetadataLoad to MANIFEST_PARSED
this.hls.on(Hls.Events.MANIFEST_PARSED, this.onMetadataLoad.bind(this));
}
onMetadataLoad(){
//Start the video
this.video.play();
}
}
class hlsLiveStreamHandler extends hlsBase{
constructor(client, player, media){
//Call derived constructor
super(client, player, media, "livehls");
}
}