Question

I have a MP4/H264 video clip which is being captured so that it grows every 4 seconds and its metadata is dynamically refreshed. Since this is not fragmented MP4 I cannot use MediaSource API to manipulate chunks.

I'm looking for a way to update/refresh the duration of the video during playback without the need to reload the whole clip.

In short words I'm looking for a way to do the following in more user-friendly way.

setInterval(function() {
   video.src = video.src;
}, 4000);

I'd like to avoid having 2 video tags and switching from one to another with the method above. I have also tried with popcorn.js without any luck.

Using Chrome, and... only chrome so not worried about other browsers.

Any advice would be greatly appreciated!

Was it helpful?

Solution

I am not sure that is possible. As per specs:

If a src attribute of a media element is set or changed, the user agent must invoke the media element's media element load algorithm. (Removing the src attribute does not do this, even if there are source elements present.)

So if you touch the video.src the browser should invoke implicitly video.load(). In your case (setInterval) Chrome does this.

I guess you already went the route of saving the currentTime of the video before changing the src and applying it after the src change (wait for the canplay event in this case and call video.play() to resume playing)? I guess you would have some stuttering for 4 seconds refresh in your case.

It seems that you are trying to emulate a live stream as an on demand feed and I do not know a way to do this with progressive download of mp4 (read with un-fragmented MP4).

Related article.

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top