Update VideoFactory.js

This commit is contained in:
Richard Davey 2023-04-12 00:39:34 +01:00
parent ff3f92f4d5
commit ce05f42759

View file

@ -10,6 +10,73 @@ var GameObjectFactory = require('../GameObjectFactory');
/**
* Creates a new Video Game Object and adds it to the Scene.
*
* This Game Object is capable of handling playback of a video file, video stream or media stream.
*
* You can optionally 'preload' the video into the Phaser Video Cache:
*
* ```javascript
* preload () {
* this.load.video('ripley', 'assets/aliens.mp4');
* }
*
* create () {
* this.add.video(400, 300, 'ripley');
* }
* ```
*
* You don't have to 'preload' the video. You can also play it directly from a URL:
*
* ```javascript
* create () {
* this.add.video(400, 300).loadURL('assets/aliens.mp4');
* }
* ```
*
* To all intents and purposes, a video is a standard Game Object, just like a Sprite. And as such, you can do
* all the usual things to it, such as scaling, rotating, cropping, tinting, making interactive, giving a
* physics body, etc.
*
* Transparent videos are also possible via the WebM file format. Providing the video file has was encoded with
* an alpha channel, and providing the browser supports WebM playback (not all of them do), then it will render
* in-game with full transparency.
*
* ### Autoplaying Videos
*
* Videos can only autoplay if the browser has been unlocked with an interaction, or satisfies the MEI settings.
* The policies that control autoplaying are vast and vary between browser. You can, and should, read more about
* it here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
*
* If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is _loaded_,
* and it will often allow the video to play immediately:
*
* ```javascript
* preload () {
* this.load.video('pixar', 'nemo.mp4', true);
* }
* ```
*
* The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without
* audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies
* the browsers MEI settings. See the MDN Autoplay Guide for further details.
*
* Or:
*
* ```javascript
* create () {
* this.add.video(400, 300).loadURL('assets/aliens.mp4', true);
* }
* ```
*
* You can set the `noAudio` parameter to `true` even if the video does contain audio. It will still allow the video
* to play immediately, but the audio will not start.
*
* Note that due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode.
*
* More details about video playback and the supported media formats can be found on MDN:
*
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement
* https://developer.mozilla.org/en-US/docs/Web/Media/Formats
*
* Note: This method will only be available if the Video Game Object has been built into Phaser.
*
* @method Phaser.GameObjects.GameObjectFactory#video