Reference createVideo()

createVideo()

Creates a <video></video> element for simple audio/video playback.

createVideo() returns a new p5.MediaElement object. Videos are shown by default. They can be hidden by calling video.hide() and drawn to the canvas using image().

The first parameter, src, is the path the video. If a single string is passed, as in '/assets/topsecret.mp4', a single video is loaded. An array of strings can be used to load the same video in different formats. For example, ['/assets/topsecret.mp4', '/assets/topsecret.ogv', '/assets/topsecret.webm']. This is useful for ensuring that the video can play across different browsers with different capabilities. See MDN for more information about supported formats.

The second parameter, callback, is optional. It's a function to call once the video is ready to play.

Examples

Syntax

createVideo(src, [callback])

Parameters

src

path to a video file, or an array of paths for supporting different browsers.

callback

function to call once the video is ready to play.

Notice any errors or typos? Please let us know. Please feel free to edit src/dom/dom.js and open a pull request!

Related References