X_HTMLAudio_pauseFix = 12 <= X_UA[ 'Opera' ] && 0 < ' XP XPSP2 2003|XP64'.indexOf( X_UA[ 'Windows' ] ), // XP + Opera12 のみ?\r
\r
X_HTMLAudio_need1stTouch = X_UA[ 'iOS' ] || 4.2 <= X_UA[ 'AOSP' ] || X_UA[ 'ChromeWV' ] || X_UA[ 'WinPhone' ] || ( X_UA[ 'Blink' ] && X_UA[ 'Android' ] ),\r
- \r
+\r
X_HTMLAudio_playTrigger = ( X_UA[ 'WinPhone' ] && X_UA[ 'IE9' ] ) ? 'canplay' : X_UA[ 'iOS' ] ? 'suspend' : X_UA[ 'Blink' ] ? 'stalled' : 'canplaythrough',\r
- \r
- X_HTMLAudio_durationFix = X_UA[ 'iOS' ] || X_UA[ 'ChromeWV' ] || ( X_UA[ 'WinPhone' ] && X_UA[ 'IE9' ] ) || ( X_UA[ 'Windows' ] && 12 <= X_UA[ 'Opera' ] ),\r
- \r
+\r
+ X_HTMLAudio_durationFix = X_UA[ 'iOS' ] || X_UA[ 'ChromeWV' ] || ( X_UA[ 'WinPhone' ] && X_UA[ 'IE9' ] ) ||\r
+ ( X_UA[ 'Windows' ] && 12 <= X_UA[ 'Opera' ] ) || ( X_UA[ 'Blink' ] && X_UA[ 'Android' ] ),\r
+\r
X_HTMLAudio_shortPlayFix = X_UA[ 'AOSP' ]; // Android 4.1.1 でも遭遇\r
\r
if( X_Audio_constructor ){\r
'X.HTMLAudio',\r
X_Class.POOL_OBJECT,\r
{\r
- _closed : true,\r
-\r
// 1: canplaythrought|timeupdateに達している、またはdurationFixが終了している\r
// 2: READY イベント発火済\r
_readyState : 0,\r
var raw;\r
\r
this.disatcher = disatcher || this;\r
- this._closed = false;\r
this._src = source;\r
\r
if( X_HTMLAudio_shortPlayFix ){\r
ready,\r
eventType, duration, end, now;\r
\r
- if( this._closed ) return;\r
+ if( !raw ) return;\r
\r
//e.type !== 'timeupdate' && console.log( ' > ' + e.type );\r
\r
switch( e.type ){\r
\r
case X_EVENT_KILL_INSTANCE :\r
- delete this._closed;\r
this.playing && this.actualPause();\r
\r
// 【javascript】モバイル向けブラウザでも音を鳴らしたい【WebAudio】\r
this._readyState |= 1;\r
};\r
case 'canplay' : // 今すぐに再生を再開できるが、バッファリングが不十分でコンテンツを最後まで表示できないと予測している場合に発生\r
- if( this._durationFixPhase === 1 && !X_HTMLAudio_need1stTouch ){\r
+ if( this._durationFixPhase === 1 && !X_HTMLAudio_need1stTouch ){ // PC Opera12 用 durationFix\r
this._durationFixPhase = 2;\r
this.actualPlay();\r
raw.currentTime = 0; // Win8 + Opera12 で必要\r
};\r
\r
// duration は Infinity, NaN, 0 の場合があるため、これを除外する\r
- if( 0 < duration && X_Type_isFinite( duration ) ){\r
+ // chrome18 for Android は duration = 100 の間はシークができない? 28 は可能\r
+ if( 0 < duration && X_Type_isFinite( duration ) && duration !== 100 ){\r
this.duration = duration * 1000;\r
\r
if( this._durationFixPhase === 4 ){\r
\r
if( this.autoplay || this._playReserved ){\r
console.log( '☆ 再生 <- DurationFix の終了' );\r
- delete this._playReserved;\r
this.actualPlay();\r
} else\r
if( X_HTMLAudio_pauseFix ){\r
};\r
} else\r
if( this._readyState === 1 && this.duration ){\r
- this._readyState = 3;\r
+ this._readyState = 2;\r
this.disatcher[ 'asyncDispatch' ]( X_EVENT_READY );\r
console.log( '> Audio Loaded!! ' + e.type + ' d:' + ( this.duration | 0 ) );\r
} else\r
var raw = this[ '_rawObject' ],\r
e, begin, end;\r
\r
- if( this._closed ) return;\r
+ if( !raw ) return;\r
\r
- if( !raw.src ){ // X_HTMLAudio_pauseFix によって src が空になっている\r
- console.log( '○ 削除された audio.src の復帰' );\r
- raw.src = this._src;\r
- return;\r
- }; \r
+ this._playReserved = true;\r
+ \r
+ if( X_HTMLAudio_pauseFix ){\r
+ if( !raw.src ){ // X_HTMLAudio_pauseFix によって src が空になっている\r
+ console.log( '○ 削除された audio.src の復帰' );\r
+ raw.src = this._src;\r
+ return;\r
+ };\r
+ if( this._durationFixPhase < 2 ){\r
+ return;\r
+ }; \r
+ };\r
\r
if( this._touchState === 2 ){\r
e = X_EventDispatcher_CURRENT_EVENTS[ X_EventDispatcher_CURRENT_EVENTS.length - 1 ];\r
};\r
this._touchState = 3;\r
} else\r
- if( this._readyState !== 3 && this._durationFixPhase < 2 ){\r
- this._playReserved = true;\r
+ if( this._readyState !== 2 && this._durationFixPhase < 2 ){\r
return;\r
};\r
\r
+ delete this._playReserved;\r
+ \r
if( this._durationFixPhase & 3 ){ // 1 or 2\r
console.log( '▲ DurationFix の開始' );\r
this._durationFixPhase = 4;\r
} else\r
if( X_HTMLAudio_needPlayForSeek || forcePlay ){\r
raw.play();\r
- //console.log( '[HTMLAudio] currentTime より先.' );\r
};\r
\r
//http://himaxoff.blog111.fc2.com/blog-entry-97.html\r