/* 录音 https://github.com/xiangyuecn/Recorder src: app-support/app.js,app-support/app-ios-weixin-support.js,app-support/app-native-support.js */ !function(){"use strict";var n=/MicroMessenger/i.test(navigator.userAgent),u=window.RecordAppBaseFolder||"/Recorder/dist/",e=window.OnRecordAppInstalled,l=[{Key:"Native",Support:function(e){e(!1)},Config:{}},{Key:"IOS-Weixin",Support:function(e){d.AlwaysUseWeixinJS||!Recorder.Support()?e(n):e(!1)},Config:{WxReady:function(e){e(null,"未实现IOS-Weixin.Config.WxReady")},DownWxMedia:function(e,n,t){t("下载素材接口DownWxMedia未实现")},AMREngine:[{url:u+"engine/beta-amr.js",check:function(){return!Recorder.prototype.amr}}]},ExtendDefault:!0},{Key:"Default",Support:function(e){e(!0)},Config:{paths:[{url:u+"recorder-core.js",check:function(){return!window.Recorder}},{url:u+"engine/mp3.js",check:function(){return!Recorder.prototype.mp3}}]}}],t=l[0],o=l[1],f=l[2];f.RequestPermission=function(e,n){var t=Recorder();t.open(function(){t.close(),e()},n)},f.Start=function(e,n,t){var o=d.__Rec;null!=o&&o.close(),d.__Rec=o=Recorder({type:e.type,sampleRate:e.sampleRate,bitRate:e.bitRate,onProcess:function(e,n,t,o){d.ReceivePCM(e[e.length-1],n,t,o)}}),o.appSet=e,o.open(function(){o.start(),n()},function(e){t(e)})},f.Stop=function(t,n){var o=d.__Rec;if(o){var r=function(){for(var e in o.close(),o.set)o.appSet[e]=o.set[e];d.__Rec=null};o.stop(function(e,n){r(),d.BlobRead(e,n,t)},function(e){r(),n(e)})}else n("未开始录音")};var d={LM:"2019-4-23 14:51:14",Current:0,IsWx:n,BaseFolder:u,AlwaysUseWeixinJS:!1,Platforms:{Native:t,Weixin:o,Default:f},Js:function(r,i,a,e){var s=(e=e||window).document,c=function(e){if(e>=r.length)i();else{var n=r[e],t=n.url;if(!1!==n.check()){var o=s.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("src",t),o.onload=function(){c(e+1)},o.onerror=function(e){a("请求失败:"+(e.message||"-")+","+t)},s.body.appendChild(o)}else c(e+1)}};c(0)},BlobRead:function(e,n,t){var o=new FileReader;o.onloadend=function(){t({mime:e.type,duration:n,data:(/.+;\s*base64\s*,\s*(.+)$/i.exec(o.result)||[])[1]})},o.readAsDataURL(e)},ReceivePCM:function(e,n,t,o){d.OnProcess&&d.OnProcess([e],n,t,o)},Install:function(t,o){var r=d.__reqs||(d.__reqs=[]);r.push({s:t,f:o}),t=function(){i("s",arguments)},o=function(e,n){i("f",arguments)};var i=function(e,n){for(var t=0;t=r.length)return p.decodeTime=Date.now()-c,void function(){a||(a=Date.now());for(var e=[],n=0;n=v.length)r();else{var e=v[t];g.DownWxMedia({mediaId:e,transform_mediaIds:v.join(","),transform_type:d.type,transform_bitRate:d.bitRate,transform_sampleRate:d.sampleRate},function(e){p.list.push(e),e.duration?r():/amr/i.test(e.mime)?(t++,i()):f("微信服务器返回了未知音频类型:"+e.mime)},function(e){f("下载音频失败:"+e)})}},a=0,s=function(){if(a>=n.length)return p.uploadTime=Date.now()-c,void i();var e=n[a];console.log("微信录音片段"+a+" wx.playVoice({localId:'"+e+"'})"),wx.uploadVoice({localId:e,isShowProgressTips:0,fail:f,success:function(e){var n=e.serverId;console.log("serverId:"+n),v.push(n),a++,s()}})},c=Date.now();s()},m=r.timeout;return r.err?(console.error(r.err,m),void f("录制失败,已录制"+m.length+"分钟,但后面出错:"+r.err)):m.length&&Date.now()-m[m.length-1].time<900?(r.wx.stopRecord(),void t()):void r.wx.stopRecord({fail:f,success:function(e){var n=Date.now();m.push({res:e,duration:n-r.startTime,time:n}),t()}})}f("未开始录音")}}(),function(){"use strict";var s=RecordApp,e=s.Platforms.Native;e.Config;e.IsInit=!0,window.top.NativeRecordReceivePCM=function(e,n,t){for(var o,r=e.length,i=0,a=0;a