bbc / VideoContext

An experimental HTML5 & WebGL video composition and rendering API.
http://bbc.github.io/VideoContext/
Apache License 2.0
1.33k stars 157 forks source link

Media Fragments #149

Closed dr-offig closed 5 years ago

dr-offig commented 5 years ago

Video context doesn't seem to play well with Media Fragments. I am hoping to loop different subsections of a video. But, for example, in the code playground the following doesn't behave as expected

var videoNode1 = vc.video("../../assets/introductions-rant.mp4#t=1,5", 0, 2, { loop: true });
var videoNode2 = vc.video("../../assets/introductions-rant.mp4#t=4,8", 0, 2, { loop: true });
var videoNode3 = vc.video("../../assets/introductions-rant.mp4#t=9,15", 0, 2, { loop: true });

Also tried

var videoNode1 = vc.video("../../assets/introductions-rant.mp4#t=1,5", 1, 2, { loop: true });
var videoNode2 = vc.video("../../assets/introductions-rant.mp4#t=4,8", 4, 2, { loop: true });
var videoNode3 = vc.video("../../assets/introductions-rant.mp4#t=9,15", 9, 2, { loop: true });
PTaylour commented 5 years ago

Yep, videocontext takes that second argument (the sourceOffset) as the as the starting point and ignores any existing state of the video element.

It also appears that the end point (from which to loop from) is unaware of the fragment

So it would be a non breaking changes to ensure that

Implementation

Do you know of the plans for media fragments? No real browser APIs that I can see:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement

image

But would be pretty simple to parse ourselves from the src url. I guess that's the way forward.

Any thoughts?

PTaylour commented 5 years ago

adding this to my reading list: https://gingertech.net/tag/media-fragment-uri/

dr-offig commented 5 years ago

Thanks for looking at this Pete. Alternatively, can you suggest any other way to loop a section of a video using the library as it stands? I guess i'm trying to do something a bit different to what the library was designed for; i.e. interactive video stuff rather than compositional.

PTaylour commented 5 years ago

interactive video stuff rather than compositional.

Thats quite a common use for it. I'd like to make videocontext more user friendly for interactive cases.

How to loop video now

We've just released an API for custom nodes. So, for now, you could do a basic implementation in your own node.

https://codesandbox.io/embed/l7wz9qw3kq

If this works ^ for you I'll do the parsing properly and merge it into the actual VideoNode.

dr-offig commented 5 years ago

Thanks Pete, that's great! Certainly covers my use-case. API for custom nodes is an awesome development.