X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F07_audio%2F02_XHTMLAudio.js;h=39728414bfcb045a2a7eb904366dde3ee7c7afde;hb=e28511741c97176b8ffe67bb1ea0660da37f754b;hp=b15b06475ad6e0c76f19b3750a2d069fefb15f4e;hpb=20c3a948b20e52efc28fd103fc075d787c6d65d2;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/07_audio/02_XHTMLAudio.js b/0.6.x/js/07_audio/02_XHTMLAudio.js index b15b064..3972841 100644 --- a/0.6.x/js/07_audio/02_XHTMLAudio.js +++ b/0.6.x/js/07_audio/02_XHTMLAudio.js @@ -87,7 +87,7 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ _lastCurrentTime : 0, _src : '', - Constructor : function( target, source, option ){ + 'Constructor' : function( target, source, option ){ var raw; this.target = target || this; @@ -168,7 +168,10 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ X_Audio_HTMLAudioWrapper_badOperaAndroid && alert( e.type ); - X_Audio_HTMLAudioWrapper_ieMobile9Fix && e.type !== 'timeupdate' && console.log( e.type ); + // global に公開 + window[ '__rawAudio' ] = this[ '_rawObject' ]; + + /* X_Audio_HTMLAudioWrapper_ieMobile9Fix && */ e.type !== 'timeupdate' && console.log( e.type ); switch( e.type ){ case 'loadstart' : // ブラウザがコンテンツの検索を開始した場合に発生 @@ -229,7 +232,7 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ case 'ended' : if( !this._closed && this.autoLoop ){ - if( !( this.target[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_Callback_PREVENT_DEFAULT ) ){ + if( !( this.target[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_CALLBACK_PREVENT_DEFAULT ) ){ this.looped = true; this.target[ 'dispatch' ]( X_EVENT_MEDIA_LOOPED ); this.actualPlay(); @@ -241,6 +244,7 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ delete this.playing; break; + // TODO firefox で 短い音声でtimeupdate, ended が発火しない case 'timeupdate' : // 通常の再生が行われ現在の再生位置の変化が起こった場合に発生 if( X_Audio_HTMLAudioWrapper_ieMobile9Fix ){ if( this._playForDuration === 1 ){ @@ -268,10 +272,10 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ if( this.playing ){ end = X_AudioWrapper_getEndTime( this ); now = this.getActualCurrentTime(); - console.log( end + ' / ' + now ); + console.log( now + ' / ' + end ); if( 0 + end <= 0 + now ){ // なぜか iem9 で必要,,, if( this.autoLoop ){ - if( !( this.target[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_Callback_PREVENT_DEFAULT ) ){ + if( !( this.target[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_CALLBACK_PREVENT_DEFAULT ) ){ this.looped = true; this.target[ 'dispatch' ]( X_EVENT_MEDIA_LOOPED ); this.actualPlay(); @@ -365,7 +369,7 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ begin = this._beginTime = X_AudioWrapper_getStartTime( this, end, true ); if( X_Audio_HTMLAudioWrapper_shortPlayFix ){ - begin -= end - begin > 1000 ? 200 : 400; + begin -= ( end - begin > 1000 ) ? 200 : 400; begin = begin < 0 ? 0 : begin; }; @@ -385,11 +389,16 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ }; this[ '_rawObject' ].play(); this.playing = true; + } else + if( X_UA[ 'Gecko' ] ){ + // Gecko PC + Android でseek時に再生がしばしば止まる問題の修正 + this[ '_rawObject' ].play(); }; + //http://himaxoff.blog111.fc2.com/blog-entry-97.html //Firefox3.6では一度も play() していない状態で currentTime = 0 を実行するとエラーになる。 //また、GoogleChrome7 では currentTime = 0 直後に play() すると、pause()した位置前後の音が混ざることがある。(少なくとも自分の環境では) - this[ '_rawObject' ].currentTime = this._lastCurrentTime = begin / 1000; + this[ '_rawObject' ].currentTime = this._lastCurrentTime = begin / 1000 | 0; console.log( '[HTMLAudio] play ' + begin + ' -> ' + end );