浏览代码

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

davrous 9 年之前
父节点
当前提交
d94a84893c
共有 2 个文件被更改,包括 574 次插入552 次删除
  1. 565 552
      src/Audio/babylon.sound.js
  2. 9 0
      src/Audio/babylon.sound.ts

文件差异内容过多而无法显示
+ 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) {