X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F07_audio%2F01_XWebAudio.js;h=84216ed60d7c92d2698f6575bd4a71ce963fc17e;hb=dc5a75639232882249108b4f708916e9690e42b3;hp=abd163bcf86431d80ba4d4c53248fdccb9d069c0;hpb=4f345667eeb8d229766fbcd5097d733b7c26ef41;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/07_audio/01_XWebAudio.js b/0.6.x/js/07_audio/01_XWebAudio.js index abd163b..84216ed 100644 --- a/0.6.x/js/07_audio/01_XWebAudio.js +++ b/0.6.x/js/07_audio/01_XWebAudio.js @@ -32,7 +32,7 @@ if( X_Audio_WebAudio_context ){ loopEndTime : -1, seekTime : -1, duration : 0, - + playing : false, error : 0, loop : false, @@ -57,9 +57,8 @@ if( X_Audio_WebAudio_context ){ Constructor : function( proxy, url, option ){ var audio = X_Audio_WebAudio_getBuffer( url ); - this.url = url; - this.closed = false; this.proxy = proxy; + this.url = url; X_AudioWrapper_updateStates( this, option ); @@ -111,7 +110,7 @@ if( X_Audio_WebAudio_context ){ case X.Event.COMPLETE : this.error = 2; - this.proxy.asyncDispatch( { type : 'error', message : 'xhr error' } ); + this.proxy.asyncDispatch( { type : X.Event.ERROR, message : 'xhr error' } ); break; }; this.xhr.unlisten( [ X.Event.PROGRESS, X.Event.SUCCESS, X.Event.COMPLETE, X.Event.CANCELED ], this ); @@ -124,17 +123,19 @@ if( X_Audio_WebAudio_context ){ this.onDecodeSuccess && this._onDecodeComplete(); if ( !buffer ) { - this.proxy.asyncDispatch( { type : 'error', message : 'buffer is ' + buffer } ); + this.proxy.asyncDispatch( { type : X.Event.ERROR, message : 'buffer is ' + buffer } ); return; }; this.buffer = buffer; this.duration = buffer.duration * 1000; - + /* this.proxy.asyncDispatch( 'loadedmetadata' ); this.proxy.asyncDispatch( 'loadeddata' ); this.proxy.asyncDispatch( 'canplay' ); this.proxy.asyncDispatch( 'canplaythrough' ); + */ + this.proxy.asyncDispatch( X.Event.READY ); this.autoplay && X.Timer.once( 16, this, this.play ); @@ -145,7 +146,7 @@ if( X_Audio_WebAudio_context ){ console.log( 'WebAudio decode error!' ); this._onDecodeComplete(); this.error = 3; - this.proxy.asyncDispatch( { type : 'error', message : 'decode error' } ); + this.proxy.asyncDispatch( { type : X.Event.ERROR, message : 'decode error' } ); }, _onDecodeComplete : function(){ @@ -235,7 +236,7 @@ if( X_Audio_WebAudio_context ){ delete this._interval; return X_Callback_UN_LISTEN; }; - this.proxy.dispatch( 'timeupdate' ); + this.proxy.dispatch( X.Event.MEDIA_PLAYING ); }, _onEnded : function(){ @@ -257,13 +258,14 @@ if( X_Audio_WebAudio_context ){ }; if( this.loop ){ - if( !( this.proxy.dispatch( 'looped' ) & X.Callback.PREVENT_DEFAULT ) ){ + if( !( this.proxy.dispatch( X.Event.MEDIA_BEFORE_LOOP ) & X.Callback.PREVENT_DEFAULT ) ){ this.looped = true; + this.proxy.dispatch( X.Event.MEDIA_LOOPED ); this.play(); - }; + }; } else { this.pause(); - this.proxy.dispatch( 'ended' ); + this.proxy.dispatch( X.Event.MEDIA_ENDED ); }; }; }, @@ -319,18 +321,18 @@ if( X_Audio_WebAudio_context ){ } ); - + + X_Audio_BACKENDS.push( { backendName : 'Web Audio', // detect : function( proxy, source, ext ){ - proxy.asyncDispatch( X_Audio_codecs[ ext ] ? 'support' : 'nosupport' ); + proxy.asyncDispatch( X_Audio_codecs[ ext ] ? X_Audio_CAN_PLAY : X_Audio_NOT_PLAY ); }, klass : X_Audio_WebAudioWrapper } ); - };