add hls initialization error checking
This commit is contained in:
parent
2dcbbbcdc2
commit
ed3334ca6c
|
@ -12,12 +12,17 @@ function onload1() {
|
||||||
}
|
}
|
||||||
function attach_hls() {
|
function attach_hls() {
|
||||||
var video = document.getElementById('video');
|
var video = document.getElementById('video');
|
||||||
|
document.getElementById('div1').innerHTML = 'Initialization state 1<br>';
|
||||||
if (Hls.isSupported()) {
|
if (Hls.isSupported()) {
|
||||||
|
document.getElementById('div1').innerHTML = 'Initialization state 1a<br>';
|
||||||
hls = new Hls();
|
hls = new Hls();
|
||||||
hls.loadSource(videoSrc);
|
hls.loadSource(videoSrc);
|
||||||
hls.attachMedia(video);
|
hls.attachMedia(video);
|
||||||
|
document.getElementById('div1').innerHTML = 'Initialization state 1b<br>';
|
||||||
hls.on(Hls.Events.MANIFEST_PARSED, function() {
|
hls.on(Hls.Events.MANIFEST_PARSED, function() {
|
||||||
|
document.getElementById('div1').innerHTML = 'Initialization state 1c<br>';
|
||||||
video.play();
|
video.play();
|
||||||
|
document.getElementById('div1').innerHTML = 'Initialization state 1d: load completed OK<br>';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// hls.js is not supported on platforms that do not have Media Source
|
// hls.js is not supported on platforms that do not have Media Source
|
||||||
|
@ -34,10 +39,15 @@ function attach_hls() {
|
||||||
// event will be emitted; the last video event that can be reliably
|
// event will be emitted; the last video event that can be reliably
|
||||||
// listened-for when the URL is not on the white-list is 'loadedmetadata'.
|
// listened-for when the URL is not on the white-list is 'loadedmetadata'.
|
||||||
else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||||
|
document.getElementById('div1').innerHTML = 'Initialization state 2<br>';
|
||||||
video.src = videoSrc;
|
video.src = videoSrc;
|
||||||
video.addEventListener('loadedmetadata', function() {
|
video.addEventListener('loadedmetadata', function() {
|
||||||
|
document.getElementById('div1').innerHTML = 'Initialization state 2a<br>';
|
||||||
video.play();
|
video.play();
|
||||||
|
document.getElementById('div1').innerHTML = 'Initialization state 2b: load completed OK<br>';
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
document.getElementById('div1').innerHTML = 'Unable to initialize HLS: failed to detect and enable media source or mp4 support<br>';
|
||||||
}
|
}
|
||||||
} // end of attach_hls()
|
} // end of attach_hls()
|
||||||
</script>
|
</script>
|
||||||
|
@ -46,5 +56,6 @@ function attach_hls() {
|
||||||
<video id="video" controls height=600 width=800></video>
|
<video id="video" controls height=600 width=800></video>
|
||||||
<br>
|
<br>
|
||||||
<hr>
|
<hr>
|
||||||
|
<div id="div1">Initialization state 0<br></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue