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
18 * TODO preplayerror play してみたら error が出た、backend の変更。
\r
21 function X_Audio_detectBackend( proxy, sourceList, option ){
\r
22 var source = sourceList.shift() || '',
\r
23 parts = source.split( '?' )[ 0 ].split( '#' )[ 0 ].split( '.' ),
\r
24 ext = parts[ parts.length - 1 ],
\r
27 if( source && X_Audio_BACKENDS.length ){
\r
28 sup = [ proxy, option, sourceList, source, ext ];
\r
30 X_Audio_BACKENDS[ 0 ]
\r
31 .detect( source, ext )
\r
32 .listenOnce( [ 'support', 'nosupport' ], X_Audio_detectComplete, sup );
\r
34 proxy.asyncDispatch( 0, 'nobackend' );
\r
38 function X_Audio_detectComplete( e, proxy, option, sourceList, source, ext, sup ){
\r
39 var i = X_Audio_BACKENDS.indexOf( this ), backend;
\r
41 this.unlisten( [ 'support', 'nosupport' ], X_Audio_detectComplete, sup );
\r
46 proxy.asyncDispatch( 0, { type : 'backendfound', option : option, source : source } );
\r
49 if( backend = X_Audio_BACKENDS[ i + 1 ] ){
\r
50 backend.detect( source, ext ).listen( [ 'support', 'nosupport' ], X_Audio_detectComplete, sup );
\r
52 if( sourceList.length ){
\r
53 X_Audio_detectBackend( proxy, sourceList, option );
\r
55 proxy.asyncDispatch( 0, 'nobackend' );
\r
62 X_AudioProxy = X.EventDispatcher.inherits(
\r
64 X.Class.POOL_OBJECT,
\r
70 Constructor : function( sourceList, option ){
\r
71 X_Audio_detectBackend( this, sourceList, option );
\r
72 this.listenOnce( [ 'backendfound', 'nobackend', X.Event.KILL_INSTANCE ], X_AudioProxy_handleEvent );
\r
76 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].close.call( this );
\r
79 play : function( position ){
\r
80 //console.log( 'proxy play ' + this._backend );
\r
81 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].play.call( this, position );
\r
85 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].pause.call( this );
\r
89 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].stop.call( this );
\r
92 loop : function( v ){
\r
93 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].loop.call( this, v );
\r
97 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].state.call( this );
\r
100 volume : function( v ){
\r
101 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].volume.call( this, v );
\r
104 startTime : function( time ){
\r
105 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].startTime.call( this, time );
\r
108 currentTime : function( time ){
\r
109 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].currentTime.call( this, time );
\r
112 isPlaying : function(){
\r
113 return this._backend !== -1 && X_Audio_BACKENDS[ this._backend ].isPlaying.call( this );
\r
119 function X_AudioProxy_handleEvent( e ){
\r
121 case 'backendfound' :
\r
122 this.unlisten( 'nobackend', X_AudioProxy_handleEvent );
\r
123 this.source = e.source;
\r
124 this.backendName = X_Audio_BACKENDS[ this._backend ].backendName;
\r
125 X_Audio_BACKENDS[ this._backend ].register( this, e.source, e.option );
\r
132 case X.Event.KILL_INSTANCE :
\r