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

Clean up HLS client code

parent c43c9ea4
...@@ -26,26 +26,7 @@ ...@@ -26,26 +26,7 @@
<script type="module"> <script type="module">
import * as mss from './mss.js' import * as mss from './mss.js'
if(Hls.isSupported()) { var hls = new mss.HLSStream(document.getElementById("hls_video"))
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 webrtc = new mss.WebRTCStream(document.getElementById("webrtc_video")) var webrtc = new mss.WebRTCStream(document.getElementById("webrtc_video"))
</script> </script>
</body> </body>
......
...@@ -117,4 +117,23 @@ export class WebRTCStream { ...@@ -117,4 +117,23 @@ export class WebRTCStream {
this.__signaling.connect() this.__signaling.connect()
} }
} }
\ No newline at end of file
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