text: /**
   * Hilo 1.5.0 for kissy
   * Copyright 2016 alibaba.com
   * Licensed under the MIT License
   */
  KISSY.add("hilo/media/WebAudio",function(t,e,i,o){var n=function(){var t=null;try{var s=window.AudioContext||window.webkitAudioContext;s&&(t=new s)}catch(r){t=null}return e.create({Mixes:o,constructor:function(t){i.copy(this,t,!0),this._init()},src:null,loop:!1,autoPlay:!1,loaded:!1,playing:!1,duration:0,volume:1,muted:!1,_context:null,_gainNode:null,_buffer:null,_audioNode:null,_startTime:0,_offset:0,_init:function(){this._context=t,this._gainNode=t.createGain?t.createGain():t.createGainNode(),this._gainNode.connect(t.destination),this._onAudioEvent=this._onAudioEvent.bind(this),this._onDecodeComplete=this._onDecodeComplete.bind(this),this._onDecodeError=this._onDecodeError.bind(this)},load:function(){if(!this._buffer){var t=n._bufferCache[this.src];if(t)this._onDecodeComplete(t);else{var e=new XMLHttpRequest;e.src=this.src,e.open("GET",this.src,!0),e.responseType="arraybuffer",e.onload=this._onAudioEvent,e.onprogress=this._onAudioEvent,e.onerror=this._onAudioEvent,e.send()}this._buffer=!0}return this},_onAudioEvent:function(t){var e=t.type;switch(e){case"load":var i=t.target;i.onload=i.onprogress=i.onerror=null,this._context.decodeAudioData(i.response,this._onDecodeComplete,this._onDecodeError),i=null;break;case"ended":this.playing=!1,this.fire("end"),this.loop&&this._doPlay();break;case"progress":this.fire(t);break;case"error":this.fire(t)}},_onDecodeComplete:function(t){n._bufferCache[this.src]||(n._bufferCache[this.src]=t),this._buffer=t,this.loaded=!0,this.duration=t.duration,this.fire("load"),this.autoPlay&&this._doPlay()},_onDecodeError:function(){this.fire("error")},_doPlay:function(){this._clearAudioNode();var t=this._context.createBufferSource();t.start||(t.start=t.noteOn,t.stop=t.noteOff),t.buffer=this._buffer,t.onended=this._onAudioEvent,this._gainNode.gain.value=this.muted?0:this.volume,t.connect(this._gainNode),t.start(0,this._offset),this._audioNode=t,this._startTime=this._context.currentTime,this.playing=!0},_clearAudioNode:function(){var t=this._audioNode;t&&(t.onended=null,t.disconnect(0),this._audioNode=null)},play:function(){return this.playing&&this.stop(),this.loaded?this._doPlay():this._buffer||(this.autoPlay=!0,this.load()),this},pause:function(){return this.playing&&(this._audioNode.stop(0),this._offset+=this._context.currentTime-this._startTime,this.playing=!1),this},resume:function(){return this.playing||this._doPlay(),this},stop:function(){return this.playing&&(this._audioNode.stop(0),this._audioNode.disconnect(),this._offset=0,this.playing=!1),this},setVolume:function(t){return this.volume!=t&&(this.volume=t,this._gainNode.gain.value=t),this},setMute:function(t){return this.muted!=t&&(this.muted=t,this._gainNode.gain.value=t?0:this.volume),this},Statics:{isSupported:null!==t,enabled:!1,enable:function(){if(!this.enabled&&t){var e=t.createBufferSource();return e.buffer=t.createBuffer(1,1,22050),e.connect(t.destination),e.start?e.start(0,0,0):e.noteOn(0,0,0),this.enabled=!0,!0}return this.enabled},_bufferCache:{},clearBufferCache:function(t){t?this._bufferCache[t]=null:this._bufferCache={}}}})}();return n},{requires:["hilo/core/Class","hilo/util/util","hilo/event/EventMixin"]});