Phaser API Documentation

  Version: 
changeSource(key, [autoplay], [loop], [markerIn], [markerOut])

Description:

This method allows you to change the source of the current video element. It works by first stopping the current video, if playing. Then deleting the video texture, if one has been created. Finally, it makes a new video texture and starts playback of the new source through the existing video element.

The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked state, even if you change the source of the video. By changing the source to a new video you avoid having to go through the unlock process again.

Parameters:

name type arguments Default description
key string

The key of the Video this Game Object will swap to playing, as stored in the Video Cache.

autoplay boolean <optional> true

Should the video start playing immediately, once the swap is complete?

loop boolean <optional> false

Should the video loop automatically when it reaches the end? Please note that not all browsers support seamless video looping for all encoding formats.

markerIn number <optional>

Optional in marker time, in seconds, for playback of a sequence of the video.

markerOut number <optional>

Optional out marker time, in seconds, for playback of a sequence of the video.

Returns:
Description:

This Video Game Object for method chaining.

Since: 3.20.0