11 create : function( sourceList, opt_option ){
\r
12 return new X_AudioProxy( X.Type.isArray( sourceList ) ? X_Object_cloneArray( sourceList ) : [ sourceList ], opt_option || {} );
\r
16 var X_Audio_BACKENDS = [];
\r
19 * TODO preplayerror play してみたら error が出た、backend の変更。
\r
22 function X_Audio_detectBackend( proxy, sourceList, option ){
\r
23 var source = sourceList.shift() || '',
\r
24 parts = source.split( '?' )[ 0 ].split( '#' )[ 0 ].split( '.' ),
\r
25 ext = parts[ parts.length - 1 ],
\r
28 if( source && X_Audio_BACKENDS.length ){
\r
29 sup = [ proxy, option, sourceList, source, ext ];
\r
31 X_Audio_BACKENDS[ 0 ]
\r
32 .detect( source, ext )
\r
33 .listenOnce( [ 'support', 'nosupport' ], X_Audio_detectComplete, sup );
\r
35 proxy.asyncDispatch( 0, 'nobackend' );
\r
39 function X_Audio_detectComplete( e, proxy, option, sourceList, source, ext, sup ){
\r
40 var i = X_Audio_BACKENDS.indexOf( this ), backend;
\r
42 this.unlisten( [ 'support', 'nosupport' ], X_Audio_detectComplete, sup );
\r
47 proxy.asyncDispatch( 0, { type : 'backendfound', option : option, source : source } );
\r
50 if( backend = X_Audio_BACKENDS[ i + 1 ] ){
\r
51 backend.detect( source, ext ).listen( [ 'support', 'nosupport' ], X_Audio_detectComplete, sup );
\r
53 if( sourceList.length ){
\r
54 X_Audio_detectBackend( proxy, sourceList, option );
\r
56 proxy.asyncDispatch( 0, 'nobackend' );
\r
63 var X_AudioProxy = X.EventDispatcher.inherits(
\r
65 X.Class.POOL_OBJECT,
\r
71 Constructor : function( sourceList, option ){
\r
72 X_Audio_detectBackend( this, sourceList, option );
\r
73 this.listenOnce( [ 'backendfound', 'nobackend', X.Event.KILL_INSTANCE ], X_AudioProxy_handleEvent );
\r
77 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].close.call( this );
\r
80 play : function( position ){
\r
81 //console.log( 'proxy play ' + this._backend );
\r
82 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].play.call( this, position );
\r
86 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].pause.call( this );
\r
90 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].stop.call( this );
\r
93 loop : function( v ){
\r
94 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].loop.call( this, v );
\r
98 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].state.call( this );
\r
101 volume : function( v ){
\r
102 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].volume.call( this, v );
\r
105 startTime : function( time ){
\r
106 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].startTime.call( this, time );
\r
109 currentTime : function( time ){
\r
110 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].currentTime.call( this, time );
\r
113 isPlaying : function(){
\r
114 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].isPlaying.call( this );
\r
120 function X_AudioProxy_handleEvent( e ){
\r
122 case 'backendfound' :
\r
123 this.unlisten( 'nobackend', X_AudioProxy_handleEvent );
\r
124 this.source = e.source;
\r
125 this.backendName = X_Audio_BACKENDS[ this._backend ].backendName;
\r
126 X_Audio_BACKENDS[ this._backend ].register( this, e.source, e.option );
\r
133 case X.Event.KILL_INSTANCE :
\r