10 create : function( sourceList, opt_option ){
\r
11 return new X_AudioProxy( X.Type.isArray( sourceList ) ? X.copyArray( sourceList ) : [ sourceList ], opt_option || {} );
\r
15 var X_Audio_BACKENDS = [];
\r
17 function X_Audio_detectBackend( proxy, sourceList, option ){
\r
18 var source = sourceList.shift() || '',
\r
19 parts = source.split( '?' )[ 0 ].split( '#' )[ 0 ].split( '.' ),
\r
20 ext = parts[ parts.length - 1 ],
\r
23 if( source && X_Audio_BACKENDS.length ){
\r
24 sup = [ proxy, option, sourceList, source, ext ];
\r
26 X_Audio_BACKENDS[ 0 ]
\r
27 .detect( source, ext )
\r
28 .listenOnce( [ 'support', 'nosupport' ], X_Audio_detectComplete, sup );
\r
30 proxy.asyncDispatch( 0, 'nobackend' );
\r
34 function X_Audio_detectComplete( e, proxy, option, sourceList, source, ext, sup ){
\r
35 var i = X_Audio_BACKENDS.indexOf( this ), backend;
\r
37 this.unlisten( [ 'support', 'nosupport' ], X_Audio_detectComplete, sup );
\r
42 proxy.asyncDispatch( 0, { type : 'backendfound', option : option, source : source } );
\r
45 if( backend = X_Audio_BACKENDS[ i + 1 ] ){
\r
46 backend.detect( source, ext ).listen( [ 'support', 'nosupport' ], X_Audio_detectComplete, sup );
\r
48 if( sourceList.length ){
\r
49 X_Audio_detectBackend( proxy, sourceList, option );
\r
51 proxy.asyncDispatch( 0, 'nobackend' );
\r
58 X_AudioProxy = X.EventDispatcher.inherits(
\r
60 X.Class.POOL_OBJECT,
\r
66 Constructor : function( sourceList, option ){
\r
67 X_Audio_detectBackend( this, sourceList, option );
\r
68 this.listenOnce( [ 'backendfound', 'nobackend', X.Event.KILL_INSTANCE ], X_AudioProxy_handleEvent );
\r
72 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].close.call( this );
\r
75 play : function( position ){
\r
76 //console.log( 'proxy play ' + this._backend );
\r
77 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].play.call( this, position );
\r
81 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].pause.call( this );
\r
85 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].stop.call( this );
\r
88 loop : function( v ){
\r
89 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].loop.call( this, v );
\r
93 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].state.call( this );
\r
96 volume : function( v ){
\r
97 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].volume.call( this, v );
\r
100 startTime : function( time ){
\r
101 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].startTime.call( this, time );
\r
104 currentTime : function( time ){
\r
105 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].currentTime.call( this, time );
\r
108 isPlaying : function(){
\r
109 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].isPlaying.call( this );
\r
115 function X_AudioProxy_handleEvent( e ){
\r
117 case 'backendfound' :
\r
118 this.unlisten( 'nobackend', X_AudioProxy_handleEvent );
\r
119 this.source = e.source;
\r
120 this.backendName = X_Audio_BACKENDS[ this._backend ].backendName;
\r
121 X_Audio_BACKENDS[ this._backend ].register( this, e.source, e.option );
\r
128 case X.Event.KILL_INSTANCE :
\r