Video class

The Video class is used to load and control videos.

The video will be rendered to a RenderTexture and therefore can be used like any other static image content. The sample below creates a BitmapData from the video and also a VideoObject display object.

var resourceManager = ResourceManager();
resourceManager.addVideo("vid1", "video.webm");
resourceManager.load().then((_) {

  var video = resourceManager.getVideo("vid1");;

  // create a BitmapData used with a Bitmap
  var bitmapData = BitmapData.fromVideoElement(video.videoElement);
  var bitmap = Bitmap(bitmapData);

  // create a convenient VideoObject display object
  var videoObject = VideoObject(video);

Please note that a video can be used with more than one display objects. To control the video independantly from each other the clone method creates a clone of this instance.

video.clone().then((newVideo) => {
  var videoObject = VideoObject(newVideo);

If the video codec of the file is not supported by the browser, the runtime will automatically fallback to a different codec. Therefore please provide the same video with different codecs. The supported codecs are webm, mp4 and ogg.


currentTime num
Get or set the current time (playback position) of the video.
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
isPlaying bool
Returns if the video is playing or not.
loop bool
read / write
muted bool
Get or set if the video is muted.
read / write
onEnded Stream<Video>
onError Stream<Video>
onPause Stream<Video>
onPlay Stream<Video>
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
videoElement VideoElement
volume num
Get or set the volume of the video.
read / write


clone() Future<Video>
Clone this video instance and the underlying HTML VideoElement to play the video independantly from this video.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
pause() → void
Pause the video.
play() → void
Play the video.
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]

Static Properties

defaultLoadOptions VideoLoadOptions
The default video load options are used if no custom video load options are provided for the load method. This default video load options enable all supported video file formats: mp4, webm and ogg.
read / write

Static Methods

load(String url, [VideoLoadOptions videoLoadOptions]) Future<Video>
Use this method to load a video from a given url. If you don't provide videoLoadOptions the defaultLoadOptions will be used. [...]