Started work on HLS livestreaming
This commit is contained in:
parent
93265b7890
commit
c6de68b474
6 changed files with 193 additions and 29 deletions
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue