Browse Source

Try Fail Repeat, Try Fail Repeat... I probably miss the learning step

sebastien 7 years ago
parent
commit
c0674bdb4d

File diff suppressed because it is too large
+ 7780 - 7780
Playground/babylon.d.txt


File diff suppressed because it is too large
+ 7644 - 7644
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 2 - 2
dist/preview release/babylon.js


+ 6 - 4
dist/preview release/babylon.max.js

@@ -64748,15 +64748,17 @@ var BABYLON;
                 }
                 _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this._samplingMode);
                 if (!_this.video.autoplay) {
-                    _this.video.play();
-                    setTimeout(function () {
+                    var oldHandler_1 = _this.video.onplay;
+                    _this.video.onplay = function () {
+                        _this.video.pause();
+                        _this.video.onplay = oldHandler_1;
                         _this._texture.isReady = true;
                         _this._updateInternalTexture();
-                        _this.video.pause();
                         if (_this._onLoadObservable && _this._onLoadObservable.hasObservers()) {
                             _this.onLoadObservable.notifyObservers(_this);
                         }
-                    }, 9);
+                    };
+                    _this.video.play();
                 }
                 else {
                     _this._texture.isReady = true;

+ 6 - 4
dist/preview release/babylon.no-module.max.js

@@ -64715,15 +64715,17 @@ var BABYLON;
                 }
                 _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this._samplingMode);
                 if (!_this.video.autoplay) {
-                    _this.video.play();
-                    setTimeout(function () {
+                    var oldHandler_1 = _this.video.onplay;
+                    _this.video.onplay = function () {
+                        _this.video.pause();
+                        _this.video.onplay = oldHandler_1;
                         _this._texture.isReady = true;
                         _this._updateInternalTexture();
-                        _this.video.pause();
                         if (_this._onLoadObservable && _this._onLoadObservable.hasObservers()) {
                             _this.onLoadObservable.notifyObservers(_this);
                         }
-                    }, 9);
+                    };
+                    _this.video.play();
                 }
                 else {
                     _this._texture.isReady = true;

File diff suppressed because it is too large
+ 2 - 2
dist/preview release/babylon.worker.js


+ 6 - 4
dist/preview release/es6.js

@@ -64715,15 +64715,17 @@ var BABYLON;
                 }
                 _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this._samplingMode);
                 if (!_this.video.autoplay) {
-                    _this.video.play();
-                    setTimeout(function () {
+                    var oldHandler_1 = _this.video.onplay;
+                    _this.video.onplay = function () {
+                        _this.video.pause();
+                        _this.video.onplay = oldHandler_1;
                         _this._texture.isReady = true;
                         _this._updateInternalTexture();
-                        _this.video.pause();
                         if (_this._onLoadObservable && _this._onLoadObservable.hasObservers()) {
                             _this.onLoadObservable.notifyObservers(_this);
                         }
-                    }, 9);
+                    };
+                    _this.video.play();
                 }
                 else {
                     _this._texture.isReady = true;

File diff suppressed because it is too large
+ 2 - 2
dist/preview release/viewer/babylon.viewer.js


+ 6 - 4
dist/preview release/viewer/babylon.viewer.max.js

@@ -64836,15 +64836,17 @@ var BABYLON;
                 }
                 _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this._samplingMode);
                 if (!_this.video.autoplay) {
-                    _this.video.play();
-                    setTimeout(function () {
+                    var oldHandler_1 = _this.video.onplay;
+                    _this.video.onplay = function () {
+                        _this.video.pause();
+                        _this.video.onplay = oldHandler_1;
                         _this._texture.isReady = true;
                         _this._updateInternalTexture();
-                        _this.video.pause();
                         if (_this._onLoadObservable && _this._onLoadObservable.hasObservers()) {
                             _this.onLoadObservable.notifyObservers(_this);
                         }
-                    }, 9);
+                    };
+                    _this.video.play();
                 }
                 else {
                     _this._texture.isReady = true;

+ 10 - 10
src/Materials/Textures/babylon.videoTexture.ts

@@ -142,17 +142,17 @@
             );
 
             if (!this.video.autoplay) {
-                this.video.play();
-                setTimeout(() => {
-                    if (this._texture) {
-                        this._texture.isReady = true;
-                        this._updateInternalTexture();
-                        this.video.pause();
-                        if (this._onLoadObservable && this._onLoadObservable.hasObservers()) {
-                            this.onLoadObservable.notifyObservers(this);
-                        }
+                let oldHandler = this.video.onplay;
+                this.video.onplay = () => {
+                    this.video.pause();
+                    this.video.onplay = oldHandler;
+                    this._texture!.isReady = true;
+                    this._updateInternalTexture();
+                    if (this._onLoadObservable && this._onLoadObservable.hasObservers()) {
+                        this.onLoadObservable.notifyObservers(this);
                     }
-                }, 9);
+                };
+                this.video.play();
             }
             else {
                 this._texture.isReady = true;