Loader#video()

video(key, urls, loadEvent, asBlob) → {Phaser.Loader}

Adds a video file to the current load queue.

The file is not loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.

The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.

Retrieve the file via Cache.getVideo(key).

The URL can be relative or absolute. If the URL is relative the Loader.baseURL and Loader.path values will be prepended to it.

You don't need to preload a video in order to play it in your game. See Video.createVideoFromURL for details.

Parameters
Name Type Argument Default Description
key string

Unique asset key of the video file.

urls string | Array.<string> | Array.<object>

Either a single string or an array of URIs or pairs of {uri: .., type: ..}.
If an array is specified then the first URI (or URI + mime pair) that is device-compatible will be selected.
For example: "boom.mp4", ['boom.mp4', 'boom.ogg', 'boom.webm'], or [{uri: "data:<opus_resource>", type: 'opus'}, 'fallback.mp4'].
BLOB and DATA URIs can be used but only support automatic detection when used in the pair form; otherwise the format must be manually checked before adding the resource.

loadEvent string <optional>
'canplaythrough'

This sets the Video source event to listen for before the load is considered complete.
'canplaythrough' implies the video has downloaded enough, and bandwidth is high enough that it can be played to completion.
'canplay' implies the video has downloaded enough to start playing, but not necessarily to finish.
'loadeddata' just makes sure that the video meta data and first frame have downloaded. Phaser uses this value automatically if the
browser is detected as being Firefox and no loadEvent is given, otherwise it defaults to canplaythrough.

asBlob boolean <optional>
false

Video files can either be loaded via the creation of a video element which has its src property set.
Or they can be loaded via xhr, stored as binary data in memory and then converted to a Blob. This isn't supported in IE9 or Android 2.
If you need to have the same video playing at different times across multiple Sprites then you need to load it as a Blob.

Returns

This Loader instance.

Source code: loader/Loader.js (Line 1111)
doc_phaser
2017-02-14 10:54:35
Comments
Leave a Comment

Please login to continue.