{\r
\r
proxy : null,\r
- xnodeAudio : null,\r
- rawAudio : null,\r
\r
_closed : true,\r
_lastUserAction : '',\r
if( option.startTime ) this._startTime = option.startTime;\r
if( option.volume ) this._volume = option.volume;\r
\r
- this.xnodeAudio = new X.EventDispatcher( this.rawAudio = X_Audio_rawAudio || new Audio( source ) )//X.Dom.Node.create( 'audio', { src : source } ).appendToRoot();//( X.Dom.Node._systemNode );\r
- .listen( [\r
+ this._rawObject = X_Audio_rawAudio || new Audio( source );//X.Dom.Node.create( 'audio', { src : source } ).appendToRoot();//( X.Dom.Node._systemNode );\r
+ \r
+ this.listen( [\r
'loadstart', 'load', 'progress', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'play', 'pause', 'loadedmetadata',\r
'loadeddata', 'waiting', 'playing', 'canplay', 'canplaythrough', 'seeking', 'seeked', 'timeupdate', 'ended',\r
- 'ratechange', 'durationchange', 'volumechange' ], this, this.handleEventProxy ); \r
+ 'ratechange', 'durationchange', 'volumechange' ], this.handleEventProxy ); \r
+ \r
if( X_Audio_rawAudio ){\r
X_Audio_rawAudio.src = source;\r
X_Audio_rawAudio.load(); // 要る?\r
X_Audio_rawAudio = null;\r
};\r
\r
- document.body.appendChild( this.rawAudio );\r
+ //document.body.appendChild( this._rawObject );\r
\r
- this.rawAudio.volume = this._volume;\r
- this.rawAudio.autoplay = false;\r
+ this._rawObject.volume = this._volume;\r
+ this._rawObject.autoplay = false;\r
option.autoplay && X.Timer.once( 100, this, this.play );\r
\r
this.listenOnce( X.Event.KILL_INSTANCE );\r
switch( e.type ){\r
\r
case X.Event.KILL_INSTANCE :\r
- this.xnodeAudio.unlisten();\r
- this.xnodeAudio.kill(); // <img> と同じく <audio> は pool した方がいいかも\r
break;\r
};\r
},\r
\r
if( X.UA.Chrome ){ // [CHROME][FIX] volume TODO どの version で 修正される?\r
// [!] delay\r
- X.Timer.once( 0, this, this._fixForChrome, [ this.rawAudio.volume ] );\r
- this.rawAudio.volume = 0;\r
+ X.Timer.once( 0, this, this._fixForChrome, [ this._rawObject.volume ] );\r
+ this._rawObject.volume = 0;\r
};\r
\r
- if( !this.rawAudio.paused ){\r
+ if( !this._rawObject.paused ){\r
this.currentTime( this._startTime );\r
};\r
- this.rawAudio.play();\r
+ this._rawObject.play();\r
},\r
\r
// [CHROME][FIX] volume\r
_fixForChrome : X.UA.Chrome && function( volume ){\r
- !this._closed && ( this.rawAudio.volume = volume );\r
+ !this._closed && ( this._rawObject.volume = volume );\r
},\r
\r
pause : function(){\r
- if( !this._closed && !this.rawAudio.error ){\r
+ if( !this._closed && !this._rawObject.error ){\r
this._lastUserAction = 'pause';\r
- this.rawAudio.pause(); \r
+ this._rawObject.pause(); \r
};\r
},\r
\r
stop : function(){\r
- if( !this._closed && !this.rawAudio.error ){\r
+ if( !this._closed && !this._rawObject.error ){\r
this._lastUserAction = 'stop';\r
- this.rawAudio.pause();\r
+ this._rawObject.pause();\r
this.currentTime( this._startTime );\r
};\r
},\r
\r
loop : function( v ){\r
if( v === undefined ) return this._loop;\r
- this.rawAudio.loop = this._loop = v;\r
+ this._rawObject.loop = this._loop = v;\r
},\r
\r
state : function(){\r
- var paused = !!this.rawAudio.paused,\r
- ended = !!this.rawAudio.ended;\r
+ var paused = !!this._rawObject.paused,\r
+ ended = !!this._rawObject.ended;\r
\r
if( this._lastUserAction === 'stop' ){\r
if( paused ){\r
};\r
\r
return {\r
- loop : this.rawAudio.loop,\r
- error : this.rawAudio.error || 0, // 0, 1 ~ 4\r
+ loop : this._rawObject.loop,\r
+ error : this._rawObject.error || 0, // 0, 1 ~ 4\r
paused : paused,\r
ended : ended,\r
- source : this.rawAudio.src || '',\r
- duration : this.rawAudio.duration || 0\r
+ source : this._rawObject.src || '',\r
+ duration : this._rawObject.duration || 0\r
};\r
},\r
\r
volume : function( v ){\r
if( v === undefined ) return this.audio.volume;\r
- this.rawAudio.volume = v;\r
+ this._rawObject.volume = v;\r
},\r
\r
startTime : function( time ){\r
},\r
\r
currentTime : function( time ){\r
- if( time === undefined ) return this.rawAudio.currentTime;\r
- this.rawAudio.currentTime = time;\r
+ if( time === undefined ) return this._rawObject.currentTime;\r
+ this._rawObject.currentTime = time;\r
},\r
\r
isPlaying : function(){\r
- return !this.rawAudio.error && !this.rawAudio.paused && !this.rawAudio.ended;\r
+ return !this._rawObject.error && !this._rawObject.paused && !this._rawObject.ended;\r
}\r
\r
}\r
X_Audio_SLAudio_LIVE_LIST = [],\r
X_Audio_SLAudio_POOL_LIST = [];\r
\r
-if( X.Pulgin.SilverLightEnabled ){\r
+if( X.Pulgin.SilverlightEnabled ){\r
\r
function getSLAudioWrapper( proxy ){\r
var i = X_Audio_SLAudio_LIVE_LIST.length;\r
X_Audio_SLAudio = X.Class._override(\r
new X.EventDispatcher(),\r
{\r
- backendName : 'SilverLight Audio',\r
+ backendName : 'Silverlight Audio',\r
\r
detect : function( source, ext ){\r
var ok = ext === 'mp3' || ext === 'wma';\r
};\r
\r
X_Audio_SLAudioWrapper = X.EventDispatcher.inherits(\r
- 'X.AV.SilverLightAudioWrapper',\r
+ 'X.AV.SilverlightAudioWrapper',\r
X.Class.POOL_OBJECT,\r
{\r
- _isSilverLight : true, // for X.EventDispatcher.listen\r
+ _isSilverlight : true, // for X.EventDispatcher.listen\r
proxy : null,\r
_onload : '',\r
_callback : null, \r
// <script id="silverlightaudio" type="text/xaml"><Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"></Canvas></script>\r
};\r
/*\r
+ * [Silverlight 2]JavaScriptコードからSilverlightのオブジェクトを利用するには?[C#、VB]\r
* http://www.atmarkit.co.jp/fdotnet/dotnettips/902slobjcallfromjs/slobjcallfromjs.html\r
- * 動いている\r
+ * このページのサンプルは sl5+firefox32 環境で動いている。xaml を js から利用する形ではなく、.xap を sl4 以下で作るのがよさそう.\r
*/\r
this.proxy = proxy;\r
this._onload = 'XAudioSilverlightOnLoad';// + ( ++X_Audio_SLAudio_uid );\r
.create( 'object', {\r
type : 'application/x-silverlight-2',\r
data : 'data:application/x-silverlight-2,',\r
- width : 100,\r
- height : 100\r
- }, { width : '20px', height : '20px', display : 'block', '-moz-binding' : 'none' } )\r
+ width : 1,\r
+ height : 1\r
+ })\r
.html(\r
'<param name="background" value="#00000000">' + // transparent\r
'<param name="windowless" value="true">' +\r