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 = new ResourceManager();
resourceManager.addVideo("vid1", "video.webm");
resourceManager.load().then((_) {
var video = resourceManager.getVideo("vid1");
video.play();
// create a BitmapData used with a Bitmap
var bitmapData = new BitmapData.fromVideoElement(video.videoElement);
var bitmap = new Bitmap(bitmapData);
stage.addChild(bitmap);
// create a convenient VideoObject display object
var videoObject = new VideoObject(video);
stage.addChild(videoObject);
});
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 = new VideoObject(newVideo);
stage.addChild(videoObject);
});
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.
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 providevideoLoadOptions
the defaultLoadOptions will be used.
Properties
- currentTime → num
-
Get or set the current time (playback position) of the video.
read / write - hashCode → int
-
Get a hash code for this object.
read-only, inherited - isPlaying → bool
-
Returns if the video is playing or not.
read-only - loop → bool
-
read / write
- muted → bool
-
Get or set if the video is muted.
read / write - onEnded → Stream<Video>
-
read-only
- onError → Stream<Video>
-
read-only
- onPause → Stream<Video>
-
read-only
- onPlay → Stream<Video>
-
read-only
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited - videoElement → VideoElement
-
read-only
- volume → num
-
Get or set the volume of the video.
read / write
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
clone(
) → Future<Video> -
Clone this video instance and the underlying HTML VideoElement to play the new video independantly from this video.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
pause(
) → void -
Pause the video.
-
play(
) → void -
Play the video.
-
toString(
) → String -
Returns a string representation of this object.
inherited