OSDN Git Service

Version 0.6.184, fi x X.AudioSprite & X.Audio, add X.WMPAudio.
[pettanr/clientJs.git] / 0.6.x / js / 07_audio / 01_XWebAudio.js
index 47026ef..e33630b 100644 (file)
@@ -88,6 +88,7 @@ var X_WebAudio_context      = // 4s 以下ではない iPad 2G または iPad mi
                                                                ( window[ 'AudioContext' ] || window[ 'webkitAudioContext' ] ),
        X_WebAudio_BUFFER_LIST  = [],
        X_WebAudio_need1stTouch = X_UA[ 'iOS' ],
+       X_WebAudio_touchState   = X_WebAudio_need1stTouch,
        X_WebAudio,
        X_WebAudio_BufferLoader,
        X_WebAudio_fpsFix;
@@ -122,9 +123,13 @@ if( X_WebAudio_context ){
                        },
                        
                        handleEvent : function( e ){
+                               var i, l;
+                               
                                switch( e.type ){
                                        case X_EVENT_PROGRESS :
-                                               this[ 'dispatch' ]( { type : 'progress', 'percent' : e[ 'percent' ] } );
+                                               for( i = 0, l = this.webAudioList.length; i < l; ++i ){
+                                                       this.webAudioList[ i ][ 'dispatch' ]( { type : X_EVENT_PROGRESS, 'percent' : e[ 'percent' ] } );
+                                               };
                                                return;
                                        
                                        case X_EVENT_SUCCESS :
@@ -298,9 +303,6 @@ if( X_WebAudio_context ){
                                        this.disatcher[ 'asyncDispatch' ]( X_EVENT_READY );
                        
                        console.log( 'WebAudio buffer ready' );
-                       
-                       this.autoplay && !X_WebAudio_need1stTouch && X_Timer_once( 16, this, this.actualPlay );
-                                       
                                },
                        
                        actualPlay : function(){
@@ -309,17 +311,18 @@ if( X_WebAudio_context ){
                                console.log( '[WebAudio] play abuf:' + !!this.audioBuffer );
                                
                    if( !this.audioBuffer ){
-                       this.autoplay = true;
+                       this._playReserved = true;
                        return;
                    };
                                
-                               if( X_WebAudio_need1stTouch ){
+                               if( X_WebAudio_touchState ){
                                        e = X_EventDispatcher_CURRENT_EVENTS[ X_EventDispatcher_CURRENT_EVENTS.length - 1 ];
                                        if( !e || !e[ 'pointerType' ] ){
-                                               alert( 'タッチイベント以外での play! ' + ( e ? e.type : '' ) );
+                                               // alert( 'タッチイベント以外での play! ' + ( e ? e.type : '' ) );
                                                return;
                                        };
                                };
+                               X_WebAudio_touchState = false;
                                
                                end   = X_Audio_getEndTime( this );
                                begin = X_Audio_getStartTime( this, end, true );
@@ -408,12 +411,8 @@ if( X_WebAudio_context ){
                                },
                        
                        actualPause : function(){
-                               //if( !this.playing ) return this;
-                               
                                console.log( '[WebAudio] pause' );
                                
-                               this.seekTime = this.getActualCurrentTime();
-                               
                    this._timerID && X_Timer_remove( this._timerID );
                                delete this._timerID;
                                delete this.playing;