I am trying to get the video to show how much has loaded with the code below but its not working at least not how I expect it to sometimes it shows the progress loaded but the majority of the time it does not. I have checked the console but no errors occur.
Does anybody know what I am doing wrong or if there is a better way for me to do this?
var video = document.getElementById("video");
video.addEventListener('progress', function() {
console.log(video.buffered.length);
if(video.buffered.length > 0){
var loadedPercentage = this.buffered.end(0) / this.duration;
}
});
<div id="video_container">
<video id="video" controls width="80%" >
<source src="<? echo $src; ?>">
<track label="English" kind="subtitles" srclang="en" src="<? echo $subLink; ?>" default>
</video>
</div>