Commit 8f0fb953 by yuananting

fix:mac企微录音调试

parent 7562d98c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: wufan * @Author: wufan
* @Date: 2021-05-11 10:21:37 * @Date: 2021-05-11 10:21:37
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-06-09 19:45:43 * @LastEditTime: 2021-06-09 20:00:13
* @Description: 企业微信api * @Description: 企业微信api
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -20,7 +20,7 @@ export default class WechatApi { ...@@ -20,7 +20,7 @@ export default class WechatApi {
const res = result.result; const res = result.result;
this.config({ this.config({
beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题 beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: res.appId, // 必填,企业微信的corpID appId: res.appId, // 必填,企业微信的corpID
timestamp: res.timestamp, // 必填,生成签名的时间戳 timestamp: res.timestamp, // 必填,生成签名的时间戳
nonceStr: res.nonceStr, // 必填,生成签名的随机串 nonceStr: res.nonceStr, // 必填,生成签名的随机串
...@@ -30,6 +30,7 @@ export default class WechatApi { ...@@ -30,6 +30,7 @@ export default class WechatApi {
"shareToExternalContact", "shareToExternalContact",
"selectExternalContact", "selectExternalContact",
"selectEnterpriseContact", "selectEnterpriseContact",
"startRecord",
], ],
}); });
...@@ -130,4 +131,10 @@ export default class WechatApi { ...@@ -130,4 +131,10 @@ export default class WechatApi {
}); });
}); });
} }
static startRecord() {
if (Platform.isWorkWx()) {
wx.startRecord();
}
}
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-03-18 10:01:28 * @Date: 2020-03-18 10:01:28
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-06-09 19:45:21 * @LastEditTime: 2021-06-09 19:59:27
* @Description: 录音组件 * @Description: 录音组件
*/ */
...@@ -35,6 +35,7 @@ class XMRecord extends Component { ...@@ -35,6 +35,7 @@ class XMRecord extends Component {
componentDidMount() { componentDidMount() {
// 获取录音设备 // 获取录音设备
this.getAudioRecorderDevice(); this.getAudioRecorderDevice();
WechatApi.initConfig({ isAgentConfig: false, url: window.location.href.split('#')[0] })
} }
componentWillUnmount() {} componentWillUnmount() {}
...@@ -86,15 +87,28 @@ class XMRecord extends Component { ...@@ -86,15 +87,28 @@ class XMRecord extends Component {
}; };
handleStartRecord = () => { handleStartRecord = () => {
navigator.mediaDevices alert("是企微", Platform.isWorkWx())
.getUserMedia({ if(Platform.isWorkWx()) { // 企业微信
audio: true, alert("进入")
}) WechatApi.startRecord({
.then((stream) => { success: function (res) {
this.mMediaRecorder = new AudioRecorder(stream); alert("开始录音", res)
this.mMediaRecorder.start(); },
this.handleCountTime(); fail: function (res) {
}, this.openDeviceFailure); alert("未开始录音", res)
}
});
} else {
navigator.mediaDevices
.getUserMedia({
audio: true,
})
.then((stream) => {
this.mMediaRecorder = new AudioRecorder(stream);
this.mMediaRecorder.start();
this.handleCountTime();
}, this.openDeviceFailure);
}
}; };
onProcessData = (audioData) => { onProcessData = (audioData) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment