OSDN Git Service

Version 0.6.92, bugfix for ie.
[pettanr/clientJs.git] / 0.6.x / js / 06_audio / 01_XHTML5Audio.js
index efbae42..827bed8 100644 (file)
@@ -1,4 +1,4 @@
-/*\r
+/*\r
  * original : uupaa-js HTML5Audio.js\r
  * https://code.google.com/p/uupaa-js/source/browse/trunk/0.8/src/Audio/HTML5Audio.js?r=568\r
  */\r
@@ -137,8 +137,6 @@ if( window.HTMLAudioElement ){
                {\r
                        \r
                        proxy           : null,\r
-                       xnodeAudio      : null,\r
-                       rawAudio        : null,\r
                        \r
                        _closed         : true,\r
                        _lastUserAction : '',\r
@@ -156,21 +154,23 @@ if( window.HTMLAudioElement ){
                                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
@@ -180,8 +180,6 @@ if( window.HTMLAudioElement ){
                                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
@@ -239,44 +237,44 @@ if( window.HTMLAudioElement ){
                        \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
@@ -286,18 +284,18 @@ if( window.HTMLAudioElement ){
                            };\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
@@ -306,12 +304,12 @@ if( window.HTMLAudioElement ){
                        },\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
@@ -319,3 +317,10 @@ if( window.HTMLAudioElement ){
        \r
 };\r
 \r
+\r
+\r
+\r
+\r
+\r
+\r
+\r