OSDN Git Service

rename files & fix X.EventDispatcher.
[pettanr/clientJs.git] / 0.6.x / js / 07_audio / 01_XWebAudio.js
index 66571d1..56fdc2e 100644 (file)
@@ -3,7 +3,8 @@ var X_Audio_WebAudio_context = !X_UA[ 'iPhone_4s' ]  && !X_UA[ 'iPad_2Mini1' ]
                                                                !( X_UA[ 'Gecko' ] && X_UA[ 'Android' ] ) &&
                                                                ( window.AudioContext || window.webkitAudioContext ),
        X_Audio_BUFFER_LIST      = [],
-       X_Audio_WebAudioWrapper;
+       X_Audio_WebAudioWrapper,
+       X_Audio_BufferLoader;
 
 /*
  * iPhone 4s 以下、iPad2以下、iPad mini 1以下, iPod touch 4G 以下は不可
@@ -155,7 +156,7 @@ if( X_Audio_WebAudio_context ){
                                
                                this.setState( option );
                                
-                               this[ 'listenOnce' ]( X_EVENT_KILL_INSTANCE, X_WebAudio_handleEvent );
+                               this[ 'listenOnce' ]( X_EVENT_KILL_INSTANCE, this.onKill );
                                
                                if( loader.buffer || loader.error ){
                                        this._onLoadBufferComplete();
@@ -163,6 +164,20 @@ if( X_Audio_WebAudio_context ){
                                        loader[ 'listenOnce' ]( X_EVENT_COMPLETE, this, this._onLoadBufferComplete );
                                };
                        },
+                       
+                       onKill : function(){
+                               this.loader[ 'unlisten' ]( X_EVENT_COMPLETE, this, this._onLoadBufferComplete )
+                                       .unregister( this );
+
+                               delete this.buffer;
+                               
+                               this.playing  && this.actualPause();
+                   this.source   && this._sourceDispose();
+       
+                   this._onended && X_Callback_correct( this._onended );       
+       
+                   this.gainNode && this.gainNode.disconnect();
+                       },
                                _onLoadBufferComplete : function( e ){
                                        var loader = this.loader,
                                                buffer = loader.buffer;
@@ -320,25 +335,6 @@ if( X_Audio_WebAudio_context ){
                }
        );
 
-       function X_WebAudio_handleEvent( e ){
-               switch( e.type ){
-
-                       case X_EVENT_KILL_INSTANCE :
-                               this.loader[ 'unlisten' ]( X_EVENT_COMPLETE, this, this._onLoadBufferComplete )
-                                       .unregister( this );
-
-                               delete this.buffer;
-                               
-                               this.playing  && this.actualPause();
-                   this.source   && this._sourceDispose();
-       
-                   this._onended && X_Callback_correct( this._onended );       
-       
-                   this.gainNode && this.gainNode.disconnect();
-                               break;
-               };
-       };
-
        /*
         * http://qiita.com/sou/items/5688d4e7d3a37b4e2ff1
         * L-01F 等の一部端末で Web Audio API の再生結果に特定条件下でノイズが混ざることがある。