Procházet zdrojové kódy

Fixing bug reported in forum: http://www.html5gamedevs.com/topic/22164-babylonsound-stop-and-play-mabe-set-isplaying-false

davrous před 9 roky
rodič
revize
d94a84893c
2 změnil soubory, kde provedl 574 přidání a 552 odebrání
  1. 565 552
      src/Audio/babylon.sound.js
  2. 9 0
      src/Audio/babylon.sound.ts

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 565 - 552
src/Audio/babylon.sound.js


+ 9 - 0
src/Audio/babylon.sound.ts

@@ -416,6 +416,7 @@
                 else {
                     var stopTime = time ? Engine.audioEngine.audioContext.currentTime + time : Engine.audioEngine.audioContext.currentTime;
                     this._soundSource.stop(stopTime);
+                    this._soundSource.onended = null;
                     if (!this.isPaused) {
                         this._startOffset = 0;
                     }
@@ -486,6 +487,14 @@
             meshToConnectTo.registerAfterWorldMatrixUpdate(this._registerFunc);
         }
 
+        public detachFromMesh() {
+            if (this._connectedMesh) {
+                this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc);
+                this._registerFunc = null;
+                this._connectedMesh = null;
+            }
+        }
+
         private _onRegisterAfterWorldMatrixUpdate(connectedMesh: AbstractMesh) {
             this.setPosition(connectedMesh.getBoundingInfo().boundingSphere.centerWorld);
             if (Engine.audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {