If I load the player before I have started live streaming and then start streaming after sometime it doesn't play the video, how i manage this issue?
There is my code i call for run html5 video with hls
playVideo(videoLink:string){
console.log("video link", videoLink);
const video = document.getElementsByTagName('video')[0];
if (Hls.isSupported()) {
/*var hls = new Hls({
debug: true,
});*/
var hls = new Hls();
hls.loadSource(videoLink);
hls.attachMedia(video);
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
video.play();
});
}
// hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
// When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element through the `src` property.
// This is using the built-in support of the plain video element, without using hls.js.
else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = videoLink;
video.addEventListener('canplay', function () {
video.play();
});
}
}
<div class="container-video" *ngIf="videoFinish == false; else videoStopped">
<video id="video"
width="700"
height="400"
preload="auto" controls>
</video>
</div>