Update video texture after loading

loadURL() or loadMediaStream()
This commit is contained in:
samme 2022-09-10 08:42:53 -07:00
parent 672fe0c97f
commit ed7c999a0a

View file

@ -293,6 +293,7 @@ var Video = new Class({
*/ */
this._callbacks = { this._callbacks = {
play: this.playHandler.bind(this), play: this.playHandler.bind(this),
load: this.loadHandler.bind(this),
error: this.loadErrorHandler.bind(this), error: this.loadErrorHandler.bind(this),
end: this.completeHandler.bind(this), end: this.completeHandler.bind(this),
time: this.timeUpdateHandler.bind(this), time: this.timeUpdateHandler.bind(this),
@ -853,6 +854,7 @@ var Video = new Class({
} }
video.addEventListener('error', this._callbacks.error, true); video.addEventListener('error', this._callbacks.error, true);
video.addEventListener(loadEvent, this._callbacks.load, true);
video.src = url; video.src = url;
@ -910,6 +912,7 @@ var Video = new Class({
video.setAttribute('preload', 'auto'); video.setAttribute('preload', 'auto');
video.addEventListener('error', this._callbacks.error, true); video.addEventListener('error', this._callbacks.error, true);
video.addEventListener(loadEvent, this._callbacks.load, true);
try try
{ {
@ -987,6 +990,18 @@ var Video = new Class({
this.video.removeEventListener('playing', this._callbacks.play, true); this.video.removeEventListener('playing', this._callbacks.play, true);
}, },
/**
* This internal method is called automatically when the video loads.
*
* @method Phaser.GameObjects.Video#loadHandler
* @private
* @since 3.60.0
*/
loadHandler: function ()
{
this.updateTexture();
},
/** /**
* This internal method is called automatically if the video fails to load. * This internal method is called automatically if the video fails to load.
* *