webpackJsonp([19],{300:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=window.exparser.registerElement({is:"wx-audio",behaviors:["wx-base","wx-player"],template:'<audio id="player" loop$="{{loop}}" style="display: none;"></audio>\n  <div id="default" class="wx-audio-default" style="display: none;">\n    <div id="poster" class="wx-audio-left">\n      <div id="button" class$="wx-audio-button {{_buttonType}}"></div>\n    </div>\n    <div class="wx-audio-right">\n      <div class="wx-audio-time" parse-text-content>{{_currentTime}}</div>\n      <div class="wx-audio-info">\n        <div class="wx-audio-name" parse-text-content>{{name}}</div>\n        <div class="wx-audio-author" parse-text-content>{{author}}</div>\n      </div>\n    </div>\n  </div>\n  <div id="fakebutton"></div>',properties:{action:{type:Object,observer:"actionChanged",public:!0},name:{type:String,value:"未知歌曲",public:!0},author:{type:String,value:"未知作者",public:!0},loop:{type:Boolean,value:!1,public:!0},controls:{type:Boolean,value:!1,observer:"controlsChanged",public:!0},_srcTimer:{type:Number},_actionTimer:{type:Number},_canSrc:{type:Boolean,value:!0},_deferredSrc:{type:String,value:""},_canAction:{type:Boolean,value:!1},_deferredAction:{type:Array,value:[]}},_reset:function(){this._buttonType="play",this._currentTime="00:00",this._duration="00:00"},_readySrc:function(){this._canSrc=!0,this.srcChanged(this._deferredSrc),this._deferredSrc=""},_readyAction:function(){var e=this;this._canAction=!0,this._deferredAction.forEach(function(t){e.actionChanged(t)},this),this._deferredAction=[]},srcChanged:function(e,t){if(e){clearTimeout(this._srcTimer),this._canAction=!1,this.$.player.src=e;var i=this;this._srcTimer=setTimeout(function(){i._reset(),i._readyAction()},0)}},posterChanged:function(e,t){this.$.poster.style.backgroundImage="url('"+e+"')"},controlsChanged:function(e,t){this.$.default.style.display=e?"":"none"},actionChanged:function(e,t){var i=this;if(e){var n=e.method;if(this.action=e,!this._canAction&&"setSrc"!==n)return void this._deferredAction.push(e);var a=null;if(null!=(a=/^set([a-z|A-Z]*)/.exec(n))){var o=a[1],r=e.data;o=o[0].toLowerCase()+o.slice(1),"currentTime"==o?0===this.$.player.readyState||1===this.$.player.readyState?function(){var e=function e(){i.$.player[o]=r,i.$.player.removeEventListener("canplay",e,!1)};i.$.player.addEventListener("canplay",e,!1)}():this.$.player[o]=r:"src"===o?this.srcChanged(r):this.triggerEvent("error",{errMsg:n+" is not an action"})}else if("play"==n||"pause"==n){if(!0===this.isBackground&&"play"===n)return;this.$.fakebutton.click()}else this.triggerEvent("error",{errMsg:n+" is not an action"});this.action=null}},attached:function(){var e=this,t=this.$.player;this.$.button.onclick=function(t){t.stopPropagation(),e.action={method:e._buttonType}},this.$.fakebutton.onclick=function(i){i.stopPropagation(),e.action&&"function"==typeof t[e.action.method]&&t[e.action.method]()},WeixinJSBridge.subscribe("audio_"+this.id+"_actionChanged",function(t){e.action=t}),WeixinJSBridge.publish("audioInsert",{audioId:this.id}),wx.onAppEnterBackground(function(t){e.$.player.pause(),e.isBackground=!0}),wx.onAppEnterForeground(function(t){e.isBackground=!1})}})}});