text: var __extends=this&&this.__extends||function(e,t){function i(){this.constructor=e}for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o]);e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)},egret;!function(e){var t;!function(e){function t(e){o.indexOf(e)<0&&o.push(e)}function i(e){var t=o.indexOf(e);return t>=0?(o.splice(t,1),!0):!1}var o=[];e.$pushSoundChannel=t,e.$popSoundChannel=i}(t=e.sys||(e.sys={}))}(egret||(egret={})),function(e){}(egret||(egret={}));var egret;!function(e){}(egret||(egret={}));var egret;!function(e){var t;!function(t){var i=function(i){function o(){var e=i.call(this)||this;return e.loaded=!1,e}return __extends(o,i),Object.defineProperty(o.prototype,"length",{get:function(){if(this.originAudio)return this.originAudio.duration;throw new Error("sound not loaded!")},enumerable:!0,configurable:!0}),o.prototype.load=function(t){function i(){r(),a.indexOf("firefox")>=0&&(u.pause(),u.muted=!1),s.loaded=!0,s.dispatchEventWith(e.Event.COMPLETE)}function n(){r(),s.dispatchEventWith(e.IOErrorEvent.IO_ERROR)}function r(){u.removeEventListener("canplaythrough",i),u.removeEventListener("error",n)}var s=this;this.url=t,t||e.$error(3002);var u=new Audio(t);u.addEventListener("canplaythrough",i),u.addEventListener("error",n);var a=navigator.userAgent.toLowerCase();a.indexOf("firefox")>=0&&(u.autoplay=!0,u.muted=!0),u.load(),this.originAudio=u,o.clearAudios[this.url]&&delete o.clearAudios[this.url],o.$recycle(this.url,u)},o.prototype.play=function(i,n){i=+i||0,n=+n||0,0==this.loaded&&e.$error(1049);var r=o.$pop(this.url);null==r&&(r=this.originAudio.cloneNode()),r.autoplay=!0;var s=new t.HtmlSoundChannel(r);return s.$url=this.url,s.$loops=n,s.$startTime=i,s.$play(),e.sys.$pushSoundChannel(s),s},o.prototype.close=function(){0==this.loaded&&this.originAudio&&(this.originAudio.src=""),this.originAudio&&(this.originAudio=null),o.$clear(this.url)},o.$clear=function(e){o.clearAudios[e]=!0;var t=o.audios[e];t&&(t.length=0)},o.$pop=function(e){var t=o.audios[e];return t&&t.length>0?t.pop():null},o.$recycle=function(e,t){if(!o.clearAudios[e]){var i=o.audios[e];null==o.audios[e]&&(i=o.audios[e]=[]),i.push(t)}},o}(e.EventDispatcher);i.MUSIC="music",i.EFFECT="effect",i.audios={},i.clearAudios={},t.HtmlSound=i,e.Sound=i}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var i=function(i){function o(t){var o=i.call(this)||this;return o.$startTime=0,o.audio=null,o.isStopped=!1,o.canPlay=function(){o.audio.removeEventListener("canplay",o.canPlay);try{o.audio.currentTime=o.$startTime}catch(e){}finally{o.audio.play()}},o.onPlayEnd=function(){return 1==o.$loops?(o.stop(),void o.dispatchEventWith(e.Event.SOUND_COMPLETE)):(o.$loops>0&&o.$loops--,void o.$play())},o._volume=1,t.addEventListener("ended",o.onPlayEnd),o.audio=t,o}return __extends(o,i),o.prototype.$play=function(){if(this.isStopped)return void e.$error(1036);try{this.audio.volume=this._volume,this.audio.currentTime=this.$startTime}catch(t){return void this.audio.addEventListener("canplay",this.canPlay)}this.audio.play()},o.prototype.stop=function(){if(this.audio){this.isStopped||e.sys.$popSoundChannel(this),this.isStopped=!0;var i=this.audio;i.removeEventListener("ended",this.onPlayEnd),i.volume=0,this._volume=0,this.audio=null;var o=this.$url;window.setTimeout(function(){i.pause(),t.HtmlSound.$recycle(o,i)},200)}},Object.defineProperty(o.prototype,"volume",{get:function(){return this._volume},set:function(t){return this.isStopped?void e.$error(1036):(this._volume=t,void(this.audio&&(this.audio.volume=t)))},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"position",{get:function(){return this.audio?this.audio.currentTime:0},enumerable:!0,configurable:!0}),o}(e.EventDispatcher);t.HtmlSoundChannel=i}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var i=function(){function e(){}return e.decodeAudios=function(){if(!(e.decodeArr.length<=0||e.isDecoding)){e.isDecoding=!0;var t=e.decodeArr.shift();e.ctx.decodeAudioData(t.buffer,function(i){t.self.audioBuffer=i,t.success&&t.success(),e.isDecoding=!1,e.decodeAudios()},function(){alert("sound decode error: "+t.url+"！\nsee http://edn.egret.com/cn/docs/page/156"),t.fail&&t.fail(),e.isDecoding=!1,e.decodeAudios()})}},e}();i.canUseWebAudio=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,i.ctx=i.canUseWebAudio?new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext):void 0,i.decodeArr=[],i.isDecoding=!1,t.WebAudioDecode=i;var o=function(o){function n(){var e=o.call(this)||this;return e.loaded=!1,e}return __extends(n,o),Object.defineProperty(n.prototype,"length",{get:function(){if(this.audioBuffer)return this.audioBuffer.duration;throw new Error("sound not loaded!")},enumerable:!0,configurable:!0}),n.prototype.load=function(t){function o(){r.loaded=!0,r.dispatchEventWith(e.Event.COMPLETE)}function n(){r.dispatchEventWith(e.IOErrorEvent.IO_ERROR)}var r=this;this.url=t,t||e.$error(3002);var s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){if(4==s.readyState){var t=s.status>=400||0==s.status;t?r.dispatchEventWith(e.IOErrorEvent.IO_ERROR):(i.decodeArr.push({buffer:s.response,success:o,fail:n,self:r,url:r.url}),i.decodeAudios())}},s.send()},n.prototype.play=function(i,o){i=+i||0,o=+o||0,0==this.loaded&&e.$error(1049);var n=new t.WebAudioSoundChannel;return n.$url=this.url,n.$loops=o,n.$audioBuffer=this.audioBuffer,n.$startTime=i,n.$play(),e.sys.$pushSoundChannel(n),n},n.prototype.close=function(){},n}(e.EventDispatcher);o.MUSIC="music",o.EFFECT="effect",t.WebAudioSound=o}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var i=function(i){function o(){var o=i.call(this)||this;return o.$startTime=0,o.bufferSource=null,o.context=t.WebAudioDecode.ctx,o.isStopped=!1,o._currentTime=0,o._volume=1,o.onPlayEnd=function(){return 1==o.$loops?(o.stop(),void o.dispatchEventWith(e.Event.SOUND_COMPLETE)):(o.$loops>0&&o.$loops--,void o.$play())},o._startTime=0,o.context.createGain?o.gain=o.context.createGain():o.gain=o.context.createGainNode(),o}return __extends(o,i),o.prototype.$play=function(){if(this.isStopped)return void e.$error(1036);this.bufferSource&&(this.bufferSource.onended=null,this.bufferSource=null);var t=this.context,i=this.gain,o=t.createBufferSource();this.bufferSource=o,o.buffer=this.$audioBuffer,o.connect(i),i.connect(t.destination),o.onended=this.onPlayEnd,this._startTime=Date.now(),this.gain.gain.value=this._volume,o.start(0,this.$startTime),this._currentTime=0},o.prototype.stop=function(){if(this.bufferSource){var t=this.bufferSource;t.stop?t.stop(0):t.noteOff(0),t.onended=null,t.disconnect(),this.bufferSource=null,this.$audioBuffer=null}this.isStopped||e.sys.$popSoundChannel(this),this.isStopped=!0},Object.defineProperty(o.prototype,"volume",{get:function(){return this._volume},set:function(t){return this.isStopped?void e.$error(1036):(this._volume=t,void(this.gain.gain.value=t))},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"position",{get:function(){return this.bufferSource?(Date.now()-this._startTime)/1e3+this.$startTime:0},enumerable:!0,configurable:!0}),o}(e.EventDispatcher);t.WebAudioSoundChannel=i}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var i=function(t){function i(i,o){void 0===o&&(o=!0);var n=t.call(this)||this;return n.loaded=!1,n.closed=!1,n.heightSet=0/0,n.widthSet=0/0,n.isPlayed=!1,n.screenChanged=function(t){var i=!!n.video.webkitDisplayingFullscreen;i||(n.checkFullScreen(!1),e.Capabilities.isMobile||(n._fullscreen=i))},n._fullscreen=!0,n.onVideoLoaded=function(){n.video.removeEventListener("canplay",n.onVideoLoaded);var t=n.video;n.loaded=!0,n.posterData&&(n.posterData.width=n.getPlayWidth(),n.posterData.height=n.getPlayHeight()),t.width=t.videoWidth,t.height=t.videoHeight,n.$renderDirty=!0,window.setTimeout(function(){n.dispatchEventWith(e.Event.COMPLETE)},200)},n.src=i,n.once(e.Event.ADDED_TO_STAGE,n.loadPoster,n),i&&n.load(),n}return __extends(i,t),i.prototype.load=function(t,i){var o=this;if(void 0===i&&(i=!0),t=t||this.src,this.src=t,t||e.$error(3002),!this.video||this.video.src!=t){var n;!this.video||e.Capabilities.isMobile?(n=document.createElement("video"),this.video=n,n.controls=null):n=this.video,n.src=t,n.setAttribute("autoplay","autoplay"),n.setAttribute("webkit-playsinline","true"),n.addEventListener("canplay",this.onVideoLoaded),n.addEventListener("error",function(){return o.onVideoError()}),n.addEventListener("ended",function(){return o.onVideoEnded()}),n.load(),n.play(),n.style.position="absolute",n.style.top="0px",n.style.zIndex="-88888",n.style.left="0px",n.height=1,n.width=1,window.setTimeout(function(){return n.pause()},170)}},i.prototype.play=function(t,i){var o=this;if(void 0===i&&(i=!1),0==this.loaded)return this.load(this.src),void this.once(e.Event.COMPLETE,function(e){return o.play(t,i)},this);this.isPlayed=!0;var n=this.video;void 0!=t&&(n.currentTime=+t||0),n.loop=!!i,e.Capabilities.isMobile?n.style.zIndex="-88888":n.style.zIndex="9999",n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.height=n.videoHeight,n.width=n.videoWidth,"Windows PC"!=e.Capabilities.os&&"Mac OS"!=e.Capabilities.os&&window.setTimeout(function(){n.width=0},1e3),this.checkFullScreen(this._fullscreen)},i.prototype.checkFullScreen=function(t){var i=this.video;if(t)null==i.parentElement&&(i.removeAttribute("webkit-playsinline"),document.body.appendChild(i)),e.stopTick(this.markDirty,this),this.goFullscreen();else if(null!=i.parentElement&&i.parentElement.removeChild(i),i.setAttribute("webkit-playsinline","true"),this.setFullScreenMonitor(!1),e.startTick(this.markDirty,this),e.Capabilities.isMobile)return this.video.currentTime=0,void this.onVideoEnded();i.play()},i.prototype.goFullscreen=function(){var t,i=this.video;return t=e.web.getPrefixStyleName("requestFullscreen",i),i[t]||(t=e.web.getPrefixStyleName("requestFullScreen",i),i[t])?(i.removeAttribute("webkit-playsinline"),i[t](),this.setFullScreenMonitor(!0),!0):!0},i.prototype.setFullScreenMonitor=function(e){var t=this.video;e?(t.addEventListener("mozfullscreenchange",this.screenChanged),t.addEventListener("webkitfullscreenchange",this.screenChanged),t.addEventListener("mozfullscreenerror",this.screenError),t.addEventListener("webkitfullscreenerror",this.screenError)):(t.removeEventListener("mozfullscreenchange",this.screenChanged),t.removeEventListener("webkitfullscreenchange",this.screenChanged),t.removeEventListener("mozfullscreenerror",this.screenError),t.removeEventListener("webkitfullscreenerror",this.screenError))},i.prototype.screenError=function(){e.$error(3014)},i.prototype.exitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.oCancelFullScreen?document.oCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()},i.prototype.onVideoEnded=function(){this.pause(),this.isPlayed=!1,this.$renderDirty=!0,this.dispatchEventWith(e.Event.ENDED)},i.prototype.onVideoError=function(){this.dispatchEventWith(e.IOErrorEvent.IO_ERROR)},i.prototype.close=function(){var e=this;this.closed=!0,this.video.removeEventListener("canplay",this.onVideoLoaded),this.video.removeEventListener("error",function(){return e.onVideoError()}),this.video.removeEventListener("ended",function(){return e.onVideoEnded()}),this.pause(),0==this.loaded&&this.video&&(this.video.src=""),this.video&&this.video.parentElement&&(this.video.parentElement.removeChild(this.video),this.video=null),this.loaded=!1},i.prototype.pause=function(){this.video&&this.video.pause(),e.stopTick(this.markDirty,this),this.$renderDirty=!0},Object.defineProperty(i.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(e){this.video&&(this.video.volume=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this.video?this.video.currentTime:0},set:function(e){this.video&&(this.video.currentTime=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fullscreen",{get:function(){return this._fullscreen},set:function(t){e.Capabilities.isMobile||(this._fullscreen=!!t,this.video&&0==this.video.paused&&this.checkFullScreen(this._fullscreen))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bitmapData",{get:function(){return this.video&&this.loaded?(this._bitmapData||(this.video.width=this.video.videoWidth,this.video.height=this.video.videoHeight,this._bitmapData=new e.BitmapData(this.video),this._bitmapData.$deleteSource=!1),this._bitmapData):null},enumerable:!0,configurable:!0}),i.prototype.loadPoster=function(){var t=this,i=this.poster;if(i){var o=new e.ImageLoader;o.once(e.Event.COMPLETE,function(e){o.data;t.posterData=o.data,t.posterData.width=t.getPlayWidth(),t.posterData.height=t.getPlayHeight(),t.$renderDirty=!0},this),o.load(i)}},i.prototype.$measureContentBounds=function(e){var t=this.bitmapData,i=this.posterData;t?e.setTo(0,0,this.getPlayWidth(),this.getPlayHeight()):i?e.setTo(0,0,this.getPlayWidth(),this.getPlayHeight()):e.setEmpty()},i.prototype.getPlayWidth=function(){return isNaN(this.widthSet)?this.bitmapData?this.bitmapData.width:this.posterData?this.posterData.width:0/0:this.widthSet},i.prototype.getPlayHeight=function(){return isNaN(this.heightSet)?this.bitmapData?this.bitmapData.height:this.posterData?this.posterData.height:0/0:this.heightSet},i.prototype.markDirty=function(){return this.$renderDirty=!0,!0},i.prototype.$setHeight=function(e){this.heightSet=+e||0,this.$renderDirty=!0,t.prototype.$setHeight.call(this,e)},i.prototype.$setWidth=function(e){this.widthSet=+e||0,this.$renderDirty=!0,t.prototype.$setWidth.call(this,e)},Object.defineProperty(i.prototype,"paused",{get:function(){return this.video?this.video.paused:!0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"length",{get:function(){if(this.video)return this.video.duration;throw new Error("Video not loaded!")},enumerable:!0,configurable:!0}),i}(e.DisplayObject);t.WebVideo=i,e.Video=i}(t=e.web||(e.web={}))}(egret||(egret={}));