changelog/v3/3.60/VideoGameObject.md
Return to the Change Log index.
The Video Game Object has been fully recoded in v3.60. Previously, it had issues with RTC streams, switching tabs and preloading too many files at once. We took a good look at the state of video playback in browsers today and decided to re-write the Video Game Object from the ground up, using the new Request Video Frame API. This has resulted in a much more reliable and stable Video Game Object.
retryInterval and then try to play the video again. This continues until input is unlocked. This can happen via a tap, click or key press. The Video Game Object itself never needs to listen for this, it just needs to wait for a success Play Promise resolution.VIDEO_LOCKED event to know if the video is playback locked due to needing input.preUpdate method to check how far along the video was and then update the source texture. This is now all handled by the Request Video Frame callback, which is only invoked when a video frame is ready. This makes the Video Game Object much more efficient as it will only ever update the source texture when a new frame is decoded by the browser.VideoFile Loader File Type now does nothing more than inject a simple small object to the Video Cache. Previously, it would create a Video DOM Element, try to load it as a blob and all kinds of other things. This lead to lots of errors, especially when loading multiple videos at the same time (as the browser would run out of Video elements to use). Under v3.60 each Video Game Object is responsible for its own unique Video DOM element, allowing for much better control and reliability.VIDEO_PLAYING event allows you to listen for the video playback and restarts, especially after lack of data.VIDEO_STALLED event allows you to know when the browser has stalled playback.VIDEO_TEXTURE event allows you to know when the Video Game Object has received its first frame data and created a texture from it.VIDEO_UNSUPPORTED event allows you to know when the Video Game Object has been asked to play a video file that the browser doesn't support (handy for testing if a browser can play WebM for example).Video.loadURL has a new optional parameter crossOrigin. This allows you to specify a cross origin request type when loading the video cross-domain (thanks @rmartell)Video config will now detect for x-m4v playback support for video formats and store it in the Video.m4v property. This is used automatically by the VideoFile file loader. Fix #5719 (thanks @patrickkeenan)loadEvent parameter when loading a video has been removed.As a result, all methods in the Video class that previously had these in the parameters have been updated to remove them.
You also no longer need to specify them when loading a video:
// Previously you had to do this. Note the 5 paramters:
this.load.video('wormhole', 'wormhole.mp4', 'loadeddata', false, true);
// Now, you just specify the key, URL and the 'noAudio' boolean:
this.load.video('wormhole', 'wormhole.mp4', true);
Video.retryInterval has changed use. It's now the number of milliseconds to wait before retrying calling video.play (i.e. when polling for video unlock)Video.retry used to hold the current retry attempt. It now holds the elapsed delta time between playback attempts.Video.retryLimit has been removed.Video.loadMediaStream method no longer has the loadEvent parameter, and has gained the optional crossOrigin parameter.Video.loadURL method no longer has the loadEvent parameter. It can now also take an array of URLs as the first parameter.Video.play method will now create a Request Video Frame callback and a Video.Play promise to handle load success and error.Video.playHandler method has been removed.Video.playingHandler is a new method that specifically handles the playing event.Video.legacyPlayHandler is a new method that specifically handles the playing event for legacy browsers that don't support Promises.Video.saveTexture method is now asynchronous. Listen for the new VIDEO_TEXTURE event to know when the video texture is ready.Video.pause is a new method that will pause a playing video.Video.resume is a new method that will resume a paused video.Video.timeUpdateHandler method has been removed.Video.updateTextyre method has been removed, this is now handled by the Request Animation Frame callback.VIDEO_TIMEOUT event has been removed.Video.removeVideoElementOnDestroy property has been removed. The Video Element is now always removed when the Video Game Object is destroyed.Video.load is a new method that loads a video from the Video Cache, ready for playback with the Video.play method.Video.addLoadEventHandlers is a new method that adds the loader specific event handlers to the video element.Video.removeLoadEventHandlers is a new method that removes the loader specific event handlers from the video element.Video.addEventHandlers is a new method that adds the playback specific event handlers to the video element.Video.removeEventHandlers is a new method that removes the playback specific event handlers to the video element.Video.createPlayPromise is a new method that creates a Promise that will resolve when the video is playing, or reject if it fails to play.Video.playSuccess is a new internal method that is called automatically if the playback Promise resolves.Video.playError is a new internal method that is called automatically if the playback Promise errors.Video.stalledHandler is a new method that is called if a video stalls, for whatever reason.Video.frameReady is a new property that lets you know if the texture has been created and populated with the first frame of the video, or not.Video.isStalled is a new read-only property that lets you know if the video is currently stalled or not. This is useful for detecting if the video is buffering or not.Video.failedPlayAttempts is a new read-only property that lets you know how many times the video has failed to play.Video.metadata is a new property that contains the VideoFrameCallbackMetadata object, as populated by the Request Video Frame callback.Video.cacheKey is a new property that contains the key of the curreng video if it came from the Video Cache, otherwise it's empty.Video.isSeeking is a new read-only property that lets you know if the video is currently seeking or not.VIDEO_COMPLETE event. Using the new Request Video Frame approach and better callback handling, this should now be fixed. Fix #6192 (thanks @dino8890)setDisplayOrigin on a Video Game Object would cause the origins to be set to NaN if the Video was created without an asset key. It will now give Videos a default size, preventing this error, which is reset once a video is loaded. Fix #5560 (thanks @mattjennings)Video.loadURL method wouldn't load the video or emit the VIDEO_CREATED event unless noAudio was specified. A load event handler has been added to resolve this (thanks @samme)Return to the Change Log index.
š Read the Phaser 3 API Docs š» Browse 2000+ Code Examples š¤ Join the awesome Phaser Discord