-
Notifications
You must be signed in to change notification settings - Fork 89
Getting Started
Caleb Sacks edited this page Aug 7, 2020
·
3 revisions
<script src="path/to/vidar"></script>
This exposes the framework as vd
.
Every movie requires a canvas to render on. Let's create one and use it to make a new movie:
window.addEventListener('load', () => {
const canvas = document.createElement("canvas");
document.body.appendChild(canvas);
const movie = new vd.Movie(canvas);
});
window.addEventListener('load', () => {
...
const video = document.createElement('video');
video.src = "path/to/video.mp4";
video.onloadeddata = () => {
// Fit canvas (movie) to video
canvas.width = video.videoWidth; // movie.width is synonymous with canvas.width
canvas.height = video.videoHeight;
...
};
})
video.onloadeddata = () => {
...
movie
// add a video layer at 0s in the timeline
.addLayer(new vd.layer.Video(0, video))
.play();
};
The full source code can be found here.