Introduction
A video can be played using the video component. This can be used for intros, or cut-scenes for example.
The video component
const intro = add([
pos(200, 100), // Where to place the video
video("intro.mp4"),
]);
intro.play();
Play, pause, rewind
The video doesn’t automatically start playing, for that intro.start()
needs to be called. To pause the video there is intro.pause()
. If you want stop functionality, you can call intro.pause()
and set intro.currentTime
to 0.
Play position
The play position, aka intro/currentTime
, can be get and set. The relative position can be computed by dividing by intro.duration
.