X-Git-Url: http://git.osdn.jp/view?p=pettanr%2FclientJs.git;a=blobdiff_plain;f=0.6.x%2Fjs%2F07_audio%2F01_XWebAudio.js;fp=0.6.x%2Fjs%2F07_audio%2F01_XWebAudio.js;h=98eee1bd17abf40e1fe58f825b3372d6ec1cfd3b;hp=5e9729983e94853f23eb2e1e65ef42c14fd2e184;hb=d3d95fb0bc2ab2f61c7f15746b2d64078ef39af8;hpb=f738ee152d8c3c6916b4d5234239c3a1c918e195 diff --git a/0.6.x/js/07_audio/01_XWebAudio.js b/0.6.x/js/07_audio/01_XWebAudio.js index 5e97299..98eee1b 100644 --- a/0.6.x/js/07_audio/01_XWebAudio.js +++ b/0.6.x/js/07_audio/01_XWebAudio.js @@ -224,7 +224,7 @@ if( X_WebAudio_context ){ _startPos : 0, _endPosition : 0, _startTime : 0, - _timerID : 0, + //_timerID : 0, _interval : 0, audioBuffer : null, bufferSource : null, @@ -354,8 +354,8 @@ if( X_WebAudio_context ){ //console.log( '> use onended' ); //this.bufferSource.onended = this._onended || ( this._onended = X_Closure_create( this, this._onEnded ) ); //} else { - this._timerID && X_Timer_remove( this._timerID ); - this._timerID = X_Timer_once( end - begin, this, this._onEnded ); + //this._timerID && X_Timer_remove( this._timerID ); + //this._timerID = X_Timer_once( end - begin, this, this._onEnded ); //}; if( this.bufferSource.start ){ @@ -368,7 +368,8 @@ if( X_WebAudio_context ){ this._startPos = begin; this._endPosition = end; this._startTime = X_WebAudio_context.currentTime * 1000; - this._interval = this._interval || X_Timer_add( 1000, 0, this, this._onInterval ); + // this._interval = this._interval || X_Timer_add( 1000, 0, this, this._onInterval ); + this._interval = this._interval || X_Timer_add( 100, 0, this, this._onEnded ); }, _sourceDispose : function(){ @@ -377,17 +378,18 @@ if( X_WebAudio_context ){ delete this.bufferSource; }, + /* _onInterval : function(){ if( !this.playing ){ delete this._interval; return X_CALLBACK_UN_LISTEN; }; this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING ); - }, - + }, */ + _onEnded : function(){ var time; - delete this._timerID; + //delete this._timerID; if( this.playing ){ time = X_WebAudio_context.currentTime * 1000 - this._startTime - this._endPosition + this._startPos | 0; @@ -397,9 +399,10 @@ if( X_WebAudio_context ){ if( time < 0 ) return; } else { if( time < 0 ){ + this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING ); //console.log( '> onEnd crt:' + ( X_WebAudio_context.currentTime * 1000 ) + ' startTime:' + this._startTime + // ' from:' + this._startPos + ' to:' + this._endPosition ); - this._timerID = X_Timer_once( -time, this, this._onEnded ); + // this._timerID = X_Timer_once( -time, this, this._onEnded ); return; }; }; @@ -409,6 +412,9 @@ if( X_WebAudio_context ){ this.looped = true; this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_LOOPED ); this.actualPlay(); + } else { + delete this._interval; + return X_CALLBACK_UN_LISTEN; }; } else { this.actualPause(); @@ -420,8 +426,10 @@ if( X_WebAudio_context ){ actualPause : function(){ console.log( '[WebAudio] pause' ); - this._timerID && X_Timer_remove( this._timerID ); - delete this._timerID; + //this._timerID && X_Timer_remove( this._timerID ); + //delete this._timerID; + this._interval && X_Timer_remove( this._interval ); + delete this._interval; delete this.playing; if( this.bufferSource ){