English
Appearance
English
Appearance
Related reference: Scene API / Video
The advanced Web API provides three kinds of video objects:
createVideo()createAlphaVideo()createKeyingVideo()const video = await api.createVideo('https://your.domain.com/ar.mp4');
await api.add(video);const alphaVideo = await api.createAlphaVideo('/assets/glow.mp4');
await api.add(alphaVideo);const keyingVideo = await api.createKeyingVideo(
'/assets/green-screen.mp4',
{
// Key color to remove. Default is #00F400.
color: '#00F400',
// Color similarity (0~1). Default is 0.42.
similarity: 0.42,
// Smoothness (0~1). Default is 0.08.
smoothness: 0.08,
// Spill reduction speed (0~1). Default is 0.
spill: 0,
}
);
await api.add(keyingVideo);Although ArrayBuffer input is supported, video files are usually large and consume significant memory. Using URLs is generally the better choice.
await api.playVideo(video, {
loop: true, // Whether playback should loop
full_screen: false // Whether it should play fullscreen
});You can later change the loop setting with setVideoLoop().
await api.pauseVideo(video);
await api.stopVideo(video);
await api.playbackVideo(video, { loop: false });// Video duration
const duration = await api.getVideoDuration(video);
// Whether the video is paused
const paused = await api.getVideoPaused(video);
// Current playback position
const currentTime = await api.getVideoCurrentTime(video);
// Whether looping is enabled
const loop = await api.getVideoLoop(video);// Jump the video to a given time
await api.setVideoCurrentTime(video, 3.2);
// Set whether the video should loop
await api.setVideoLoop(video, true);play - fires when video playback startsfunction onPlay(event) {
const { type, target } = event;
}
await api.on('play', onPlay, video);pause - fires when playback pausesfunction onPause(event) {
const { type, target } = event;
}
await api.on('pause', onPause, video);ended - fires when playback finishes naturallyfunction onEnded(event) {
const { type, target } = event;
}
await api.on('ended', onEnded, video);replay - fires when playback restartsfunction onReplay(event) {
const { type, target } = event;
}
await api.on('replay', onReplay, video);Best for most regular flat-video playback scenarios.
Best when you already have a platform-supported alpha-video asset and want to overlay it directly into the scene.
Best for green-screen or blue-screen style keying, but the final visual quality depends heavily on source quality and keying configuration.
Note
All videos are rendered inside the 3D scene, not as regular HTML video elements on the page.
Browsers enforce strict autoplay rules. Even though Kivicube handles some compatibility issues internally, you should still pay close attention to these cases:
So before shipping any video-heavy content, always run a full regression pass on real target devices.