Commit 7b05657c authored by Jakub Adam's avatar Jakub Adam
Browse files

Clean up HLS client code

parent c43c9ea4
......@@ -26,26 +26,7 @@
<script type="module">
import * as mss from './mss.js'
if(Hls.isSupported()) {
var hls_video = document.getElementById('hls_video');
var hls = new Hls({
liveDurationInfinity: true
});
hls.on(Hls.Events.ERROR, (e, data) => {
if (data.type == "networkError") {
setTimeout(() => {
hls.recoverMediaError()
hls.loadSource('hls/playlist.m3u8')
}, 1000)
}
console.log(data)
})
hls.attachMedia(hls_video);
hls.loadSource('hls/playlist.m3u8');
}
var hls = new mss.HLSStream(document.getElementById("hls_video"))
var webrtc = new mss.WebRTCStream(document.getElementById("webrtc_video"))
</script>
</body>
......
......@@ -118,3 +118,22 @@ export class WebRTCStream {
this.__signaling.connect()
}
}
export class HLSStream {
constructor(video) {
this.__hls = new Hls({liveDurationInfinity: true});
this.__hls.on(Hls.Events.ERROR, (e, data) => {
if (data.type == "networkError") {
setTimeout(() => {
this.__hls.recoverMediaError()
this.__hls.loadSource('hls/playlist.m3u8')
}, 1000)
}
console.log(data)
})
this.__hls.attachMedia(video);
this.__hls.loadSource('hls/playlist.m3u8');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment