From 5d9dee8a99d27f4c251b5ef8f77b510ccd202b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E5=9D=9A=E6=9E=9C?= <753610399@qq.com> Date: Tue, 28 Jan 2020 04:42:25 +0800 Subject: [PATCH] =?UTF-8?q?RecordApp=E6=B7=BB=E5=8A=A0UseLazyLoad=E9=80=89?= =?UTF-8?q?=E9=A1=B9=EF=BC=8C=E5=AF=B9=E9=83=A8=E5=88=86=E9=9D=9E=E6=A0=B8?= =?UTF-8?q?=E5=BF=83=E7=BB=84=E4=BB=B6=E8=BF=9B=E8=A1=8C=E5=BB=B6=E8=BF=9F?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app-support-sample/index.html | 4 ++-- assets/npm-home/hash-history.txt | 8 ++++---- dist/app-support/app.js | 2 +- src/app-support/app.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app-support-sample/index.html b/app-support-sample/index.html index c0225e1..26e3284 100644 --- a/app-support-sample/index.html +++ b/app-support-sample/index.html @@ -72,7 +72,7 @@ }); //可以设置组件是否进行延迟加载,默认会延迟加载,不会阻塞Install -RecordApp.UseLazyLoad=!!(+localStorage["RecordApp_UseLazyLoad"]||0); +RecordApp.UseLazyLoad=!(+localStorage["RecordApp_UseLazyLoadDisable"]||0); //立即加载环境,自动把Recorder加载进来 RecordApp.Install(function(){ @@ -854,7 +854,7 @@ reclog("提示:部分组件可能会设置在Install成功后进行延迟加载,Start、Stop操作在组件未加载完时会等待OnLazyReady事件触发,可通过设置RecordApp.UseLazyLoad=false关闭此特性(会阻塞Install导致RequestPermission变慢),当前已启用":"red'>当前已关闭")+"此特性"); window.changeUseLazyLoad=function(){ - localStorage["RecordApp_UseLazyLoad"]=RecordApp.UseLazyLoad?0:1; + localStorage["RecordApp_UseLazyLoadDisable"]=RecordApp.UseLazyLoad?1:0; location.reload(); }; RecordApp.Current.OnLazyReady(function(){ diff --git a/assets/npm-home/hash-history.txt b/assets/npm-home/hash-history.txt index 02ee18c..28efead 100644 --- a/assets/npm-home/hash-history.txt +++ b/assets/npm-home/hash-history.txt @@ -1,4 +1,8 @@ [ + { + "sha1": "37aa5f16f3ff3bba8a6f7e7ee1db018007e13639", + "time": "2020-1-28 04:41:38" + }, { "sha1": "96ba713840ef578e59374ee2b012460fd4889bbc", "time": "2020-1-28 04:28:51" @@ -14,9 +18,5 @@ { "sha1": "d7949810ec706e70159f0e09860b6f627197a29d", "time": "2020-1-16 16:19:04" - }, - { - "sha1": "faa51e270e00316a1f7c005e526dde26b7ceaef1", - "time": "2020-1-15 18:02:58" } ] \ No newline at end of file diff --git a/dist/app-support/app.js b/dist/app-support/app.js index 6e67e5c..db32d7d 100644 --- a/dist/app-support/app.js +++ b/dist/app-support/app.js @@ -3,4 +3,4 @@ https://github.com/xiangyuecn/Recorder src: app-support/app.js,app-support/app-ios-weixin-support.js,app-support/app-native-support.js */ -!function(e){"use strict";var t=/MicroMessenger/i.test(navigator.userAgent),n=e.RecordAppBaseFolder||"/Recorder/dist/",o=e.OnRecordAppInstalled,u=[{Key:"Native",Support:function(n){m.AlwaysAppUseJS?n(!1):r.Config.IsApp(n)},CanProcess:function(){return!0},Config:{IsApp:function(n){n(!1)},JsBridgeRequestPermission:function(n,e){e("JsBridgeRequestPermission未实现")},JsBridgeStart:function(n,e,t){t("JsBridgeStart未实现")},JsBridgeStop:function(n,e){e("JsBridgeStop未实现")},paths:[{url:n+"app-support/app-native-support.js",check:function(){return!r.IsInit}}]},ExtendDefault:!0},{Key:"IOS-Weixin",Support:function(n){m.AlwaysUseWeixinJS||!Recorder.Support()?n(t):n(!1)},CanProcess:function(){return!1},Config:{WxReady:function(n){n(null,"未实现IOS-Weixin.Config.WxReady")},DownWxMedia:function(n,e,t){t("下载素材接口DownWxMedia未实现")},paths:[{url:n+"app-support/app-ios-weixin-support.js",check:function(){return!s.IsInit}},{url:n+"engine/beta-amr.js",lazyBeforeStop:1,check:function(){return!Recorder.prototype.amr}}]},ExtendDefault:!0},{Key:"Default",Support:function(n){n(!0)},CanProcess:function(){return!0},Config:{paths:[{url:n+"recorder-core.js",check:function(){return!e.Recorder}},{url:n+"engine/mp3.js",lazyBeforeStart:1,check:function(){return!Recorder.prototype.mp3}}]}}],r=u[0],s=u[1],v=u[2];v.RequestPermission=function(n,e){var t=m.__Rec;t&&(t.close(),m.__Rec=null);var o=Recorder();o.open(function(){n()},e)},v.Start=function(n,e,t){var o=m.__Rec;null!=o&&o.close(),m.__Rec=o=Recorder(n),o.appSet=n,o.open(function(){o.start(),e()},function(n){t(n)})},v.Stop=function(t,e){var o=m.__Rec;if(!o)return Recorder.IsOpen()&&((o=Recorder()).open(),o.close()),void e("未开始录音");var r=function(){for(var n in o.close(),o.set)o.appSet[n]=o.set[n]},n=function(n){r(),e(n),m.__Rec=null};t?o.stop(function(n,e){r(),t(n,e),m.__Rec=null},n):n("仅清理资源")};var m={LM:"2019-10-26 11:23:48",Current:0,IsWx:t,BaseFolder:n,UseLazyLoad:!0,AlwaysUseWeixinJS:!1,AlwaysAppUseJS:!1,Platforms:{Native:r,Weixin:s,Default:v},Js:function(r,s,i,n){var a=(n=n||e).document,c=function(n){if(n>=r.length)s();else{var e=r[n],t=e.url;if(!1!==e.check()){var o=a.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("src",t),o.onload=function(){c(n+1)},o.onerror=function(n){i("请求失败:"+(n.message||"-")+","+t)},a.body.appendChild(o)}else c(n+1)}};c(0)},Install:function(t,o){var r=m.__reqs||(m.__reqs=[]);r.push({s:t,f:o}),t=function(){s("s",arguments)},o=function(n,e){s("f",arguments)};var s=function(n,e){for(var t=0;t=r.length)return v.decodeTime=Date.now()-u,void function(){a||(a=Date.now());for(var n=[],e=0;e=l.length)r();else{var n=l[t];R.DownWxMedia({mediaId:n,transform_mediaIds:l.join(","),transform_type:d.type,transform_bitRate:d.bitRate,transform_sampleRate:d.sampleRate},function(n){v.list.push(n),n.duration?r():/amr/i.test(n.mime)?(t++,s()):p("微信服务器返回了未知音频类型:"+n.mime)},function(n){p("下载音频失败:"+n)})}},i=0,a=function(){if(i>=e.length)return v.uploadTime=Date.now()-c,void s();var n=e[i];console.log("微信录音片段"+i+" wx.playVoice({localId:'"+n+"'})"),wx.uploadVoice({localId:n,isShowProgressTips:0,fail:p,success:function(n){var e=n.serverId;console.log("serverId:"+e),l.push(e),i++,a()}})},c=Date.now();a()}else p("仅清理资源")},m=c.chunks;if(c.chunkErr)return console.error(c.chunkErr,m),void p("录制失败,已录制"+m.length+"分钟,但后面出错:"+c.chunkErr);if(m.length&&Date.now()-m[m.length-1].time<900)return console.error("丢弃结尾未停止太短录音"),g(),void o();c.stopJoinEnd=function(n,e){c.stopJoinEnd=null;var t=Date.now();n.localId?m.push({res:n,duration:t-c.startTime,time:t,from:e}):console.error("已忽略"+e+"数据",n),c.chunks=null,o()},c.wx.stopRecord({fail:p,success:function(n){c.stopJoinEnd&&c.stopJoinEnd(n,"stop")}})}else p("未开始录音")}}(),function(){"use strict";var s=RecordApp,n=s.Platforms.Native,i=n.Config;n.IsInit=!0;var l=window.NativeRecordReceivePCM=window.top.NativeRecordReceivePCM=function(n,e){var t=l.rec;if(t){t._appStart||t.envStart(1,e),t._appStart=1;for(var o,r=atob(n),s=r.length,i=new Int16Array(s/2),a=0,c=0,u=0;u+2<=s;c++,u+=2)o=(r.charCodeAt(u)|r.charCodeAt(u+1)<<8)<<16>>16,i[c]=o,a+=Math.abs(o);t.envIn(i,a)}else console.error("未开始录音,但收到Native PCM数据")};n.RequestPermission=function(n,e){i.JsBridgeRequestPermission(n,e)},n.Start=function(n,e,t){l.param=n;var o=Recorder(n);o.set.disableEnvInFix=!0,l.rec=o,s.__Rec=o,i.JsBridgeStart(n,e,t)},n.Stop=function(o,e){var r=function(n){e(n),l.rec=null,s.__Rec=null};i.JsBridgeStop(function(){var e=l.rec;if(l.rec=null,e){console.log("rec encode start: pcm:"+e.recSize+" src:"+e.srcSampleRate+" set:"+JSON.stringify(l.param));var t=function(){for(var n in e.set)l.param[n]=e.set[n]};if(!o)return t(),void r("仅清理资源");e.stop(function(n,e){console.log("rec encode end"),t(),o(n,e),s.__Rec=null},function(n){t(),r(n)})}else r("未开始录音")},r)}}(); \ No newline at end of file +!function(e){"use strict";var t=/MicroMessenger/i.test(navigator.userAgent),n=e.RecordAppBaseFolder||"/Recorder/dist/",o=e.OnRecordAppInstalled,u=[{Key:"Native",Support:function(n){m.AlwaysAppUseJS?n(!1):r.Config.IsApp(n)},CanProcess:function(){return!0},Config:{IsApp:function(n){n(!1)},JsBridgeRequestPermission:function(n,e){e("JsBridgeRequestPermission未实现")},JsBridgeStart:function(n,e,t){t("JsBridgeStart未实现")},JsBridgeStop:function(n,e){e("JsBridgeStop未实现")},paths:[{url:n+"app-support/app-native-support.js",check:function(){return!r.IsInit}}]},ExtendDefault:!0},{Key:"IOS-Weixin",Support:function(n){m.AlwaysUseWeixinJS||!Recorder.Support()?n(t):n(!1)},CanProcess:function(){return!1},Config:{WxReady:function(n){n(null,"未实现IOS-Weixin.Config.WxReady")},DownWxMedia:function(n,e,t){t("下载素材接口DownWxMedia未实现")},paths:[{url:n+"app-support/app-ios-weixin-support.js",check:function(){return!s.IsInit}},{url:n+"engine/beta-amr.js",lazyBeforeStop:1,check:function(){return!Recorder.prototype.amr}}]},ExtendDefault:!0},{Key:"Default",Support:function(n){n(!0)},CanProcess:function(){return!0},Config:{paths:[{url:n+"recorder-core.js",check:function(){return!e.Recorder}},{url:n+"engine/mp3.js",lazyBeforeStart:1,check:function(){return!Recorder.prototype.mp3}}]}}],r=u[0],s=u[1],v=u[2];v.RequestPermission=function(n,e){var t=m.__Rec;t&&(t.close(),m.__Rec=null);var o=Recorder();o.open(function(){n()},e)},v.Start=function(n,e,t){var o=m.__Rec;null!=o&&o.close(),m.__Rec=o=Recorder(n),o.appSet=n,o.open(function(){o.start(),e()},function(n){t(n)})},v.Stop=function(t,e){var o=m.__Rec;if(!o)return Recorder.IsOpen()&&((o=Recorder()).open(),o.close()),void e("未开始录音");var r=function(){for(var n in o.close(),o.set)o.appSet[n]=o.set[n]},n=function(n){r(),e(n),m.__Rec=null};t?o.stop(function(n,e){r(),t(n,e),m.__Rec=null},n):n("仅清理资源")};var m={LM:"2020-1-28 04:38:58",Current:0,IsWx:t,BaseFolder:n,UseLazyLoad:!0,AlwaysUseWeixinJS:!1,AlwaysAppUseJS:!1,Platforms:{Native:r,Weixin:s,Default:v},Js:function(r,s,i,n){var a=(n=n||e).document,c=function(n){if(n>=r.length)s();else{var e=r[n],t=e.url;if(!1!==e.check()){var o=a.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("src",t),o.onload=function(){c(n+1)},o.onerror=function(n){i("请求失败:"+(n.message||"-")+","+t)},a.body.appendChild(o)}else c(n+1)}};c(0)},Install:function(t,o){var r=m.__reqs||(m.__reqs=[]);r.push({s:t,f:o}),t=function(){s("s",arguments)},o=function(n,e){s("f",arguments)};var s=function(n,e){for(var t=0;t=r.length)return v.decodeTime=Date.now()-u,void function(){a||(a=Date.now());for(var n=[],e=0;e=l.length)r();else{var n=l[t];R.DownWxMedia({mediaId:n,transform_mediaIds:l.join(","),transform_type:d.type,transform_bitRate:d.bitRate,transform_sampleRate:d.sampleRate},function(n){v.list.push(n),n.duration?r():/amr/i.test(n.mime)?(t++,s()):p("微信服务器返回了未知音频类型:"+n.mime)},function(n){p("下载音频失败:"+n)})}},i=0,a=function(){if(i>=e.length)return v.uploadTime=Date.now()-c,void s();var n=e[i];console.log("微信录音片段"+i+" wx.playVoice({localId:'"+n+"'})"),wx.uploadVoice({localId:n,isShowProgressTips:0,fail:p,success:function(n){var e=n.serverId;console.log("serverId:"+e),l.push(e),i++,a()}})},c=Date.now();a()}else p("仅清理资源")},m=c.chunks;if(c.chunkErr)return console.error(c.chunkErr,m),void p("录制失败,已录制"+m.length+"分钟,但后面出错:"+c.chunkErr);if(m.length&&Date.now()-m[m.length-1].time<900)return console.error("丢弃结尾未停止太短录音"),g(),void o();c.stopJoinEnd=function(n,e){c.stopJoinEnd=null;var t=Date.now();n.localId?m.push({res:n,duration:t-c.startTime,time:t,from:e}):console.error("已忽略"+e+"数据",n),c.chunks=null,o()},c.wx.stopRecord({fail:p,success:function(n){c.stopJoinEnd&&c.stopJoinEnd(n,"stop")}})}else p("未开始录音")}}(),function(){"use strict";var s=RecordApp,n=s.Platforms.Native,i=n.Config;n.IsInit=!0;var l=window.NativeRecordReceivePCM=window.top.NativeRecordReceivePCM=function(n,e){var t=l.rec;if(t){t._appStart||t.envStart(1,e),t._appStart=1;for(var o,r=atob(n),s=r.length,i=new Int16Array(s/2),a=0,c=0,u=0;u+2<=s;c++,u+=2)o=(r.charCodeAt(u)|r.charCodeAt(u+1)<<8)<<16>>16,i[c]=o,a+=Math.abs(o);t.envIn(i,a)}else console.error("未开始录音,但收到Native PCM数据")};n.RequestPermission=function(n,e){i.JsBridgeRequestPermission(n,e)},n.Start=function(n,e,t){l.param=n;var o=Recorder(n);o.set.disableEnvInFix=!0,l.rec=o,s.__Rec=o,i.JsBridgeStart(n,e,t)},n.Stop=function(o,e){var r=function(n){e(n),l.rec=null,s.__Rec=null};i.JsBridgeStop(function(){var e=l.rec;if(l.rec=null,e){console.log("rec encode start: pcm:"+e.recSize+" src:"+e.srcSampleRate+" set:"+JSON.stringify(l.param));var t=function(){for(var n in e.set)l.param[n]=e.set[n]};if(!o)return t(),void r("仅清理资源");e.stop(function(n,e){console.log("rec encode end"),t(),o(n,e),s.__Rec=null},function(n){t(),r(n)})}else r("未开始录音")},r)}}(); \ No newline at end of file diff --git a/src/app-support/app.js b/src/app-support/app.js index 7c5b065..cfc27e6 100644 --- a/src/app-support/app.js +++ b/src/app-support/app.js @@ -254,7 +254,7 @@ Default.Stop=function(success,fail){ var App={ -LM:"2019-10-26 11:23:48" +LM:"2020-1-28 04:38:58" ,Current:0 ,IsWx:IsWx ,BaseFolder:BaseFolder