Skip to content

Commit e3b4ec1

Browse files
committed
Don't access currentTime if no video loaded
1 parent 29b9801 commit e3b4ec1

1 file changed

Lines changed: 22 additions & 20 deletions

File tree

src/gameobjects/video/Video.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ var Video = new Class({
273273

274274
if (!video)
275275
{
276-
// eslint-disable-next-line no-console
277-
console.error('Video not loaded');
276+
console.warn('Video not loaded');
278277

279278
return this;
280279
}
@@ -664,30 +663,33 @@ var Video = new Class({
664663
{
665664
var video = this.video;
666665

667-
var currentTime = video.currentTime;
668-
669-
// Don't render a new frame unless the video has actually changed time
670-
if (video && currentTime !== this._lastUpdate)
666+
if (video)
671667
{
672-
this._lastUpdate = currentTime;
673-
674-
this.updateTexture();
668+
var currentTime = video.currentTime;
675669

676-
if (currentTime >= this._markerOut)
670+
// Don't render a new frame unless the video has actually changed time
671+
if (currentTime !== this._lastUpdate)
677672
{
678-
console.log('marker out', currentTime, this._markerOut);
673+
this._lastUpdate = currentTime;
674+
675+
this.updateTexture();
679676

680-
if (video.loop)
677+
if (currentTime >= this._markerOut)
681678
{
682-
video.currentTime = this._markerIn;
679+
console.log('marker out', currentTime, this._markerOut);
683680

684-
this.updateTexture();
681+
if (video.loop)
682+
{
683+
video.currentTime = this._markerIn;
685684

686-
this._lastUpdate = currentTime;
687-
}
688-
else
689-
{
690-
this.stop();
685+
this.updateTexture();
686+
687+
this._lastUpdate = currentTime;
688+
}
689+
else
690+
{
691+
this.stop();
692+
}
691693
}
692694
}
693695
}
@@ -837,7 +839,7 @@ var Video = new Class({
837839

838840
if (!this.videoTexture)
839841
{
840-
this.videoTexture = this.scene.sys.textures.create(this._key, video, width, height, this.flipY);
842+
this.videoTexture = this.scene.sys.textures.create(this._key, video, width, height);
841843
this.videoTextureSource = this.videoTexture.source[0];
842844
this.videoTexture.add('__BASE', 0, 0, 0, width, height);
843845

0 commit comments

Comments
 (0)