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

Append videos while playing #213

Closed lucasconstantino closed 4 years ago

lucasconstantino commented 4 years ago

Hello,

I'm exploring this library as a possible solution to a game experience which uses background videos dynamically defined based on game states. Is it supported to add new videos to the end of the video context while already playing?

dceddia commented 4 years ago

I'm only just starting to look at this library myself, but it seems that it supports adding new videos dynamically during playback. I took their CompositingNode demo and modified it to add a video node during playback: https://codesandbox.io/s/videocontext-adding-video-to-end-dynamically-jo3qs

(If you see an error, click CodeSandbox's refresh icon. The demos seem to error initially and I'm not sure why)

The main change I made was to move the addition of the videoNode2 into a setTimeout that triggers 8 seconds after playback begins, and also to use the startAt and stopAt functions to set its time instead of start and stop.

I think for your use case you'd need to manually keep track of the "stop" point of the last video, so that you can add new videos after it, but it does seem to work.

lucasconstantino commented 4 years ago

@dceddia thanks so much for your reply. Question answered!