|
|
@@ -148,14 +148,15 @@ export default {
|
|
|
},
|
|
|
stopRecord() {
|
|
|
console.log("测试测试")
|
|
|
- // if(new Date().getTime() - this.recordObj.startTime < 2000){
|
|
|
- // return console.log("稍等")
|
|
|
- // }
|
|
|
+ if(new Date().getTime() - this.recordObj.startTime < 2000){
|
|
|
+ return console.log("稍等")
|
|
|
+ }
|
|
|
// 判断浏览器是否有开启录音权限
|
|
|
navigator.permissions && navigator.permissions.query({ name: 'microphone' }).then(permissionStatus => {
|
|
|
if (permissionStatus.state !== "granted") {
|
|
|
// 没有开启录音权限,直接确定停止录音
|
|
|
this.recordObj.status = "0";
|
|
|
+ this.recordObj.loading = false;
|
|
|
let iframe = this.$refs["iframeRef"];
|
|
|
iframe.contentWindow.onSessionStopped = null;
|
|
|
iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
@@ -165,28 +166,32 @@ export default {
|
|
|
}
|
|
|
console.log("测试测试222")
|
|
|
// 有权限再判断状态
|
|
|
- if(this.recordObj.status=='1'){
|
|
|
+ if(this.recordObj.status=='1' && !this.recordObj.loading){
|
|
|
console.log("测试测3333")
|
|
|
let iframe = this.$refs["iframeRef"];
|
|
|
+ this.recordObj.loading = true;
|
|
|
iframe.contentWindow.window.document
|
|
|
.getElementById("scenarioStopButton")
|
|
|
.click();
|
|
|
iframe.contentWindow.onSessionStopped = (s, e) => {
|
|
|
this.recordObj.status = "0"
|
|
|
+ this.recordObj.loading = false;
|
|
|
this.$message.success("已停止录音")
|
|
|
iframe.contentWindow.onSessionStopped = null;
|
|
|
iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
};
|
|
|
}else{
|
|
|
this.recordObj.status = "0";
|
|
|
- let iframe = this.$refs["iframeRef"];
|
|
|
- iframe.contentWindow.onSessionStopped = null;
|
|
|
- iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
+ this.recordObj.loading = false;
|
|
|
+ let iframe = this.$refs["iframeRef"];
|
|
|
+ iframe.contentWindow.onSessionStopped = null;
|
|
|
+ iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
}
|
|
|
}).catch(() => {
|
|
|
console.log("测试测4444试")
|
|
|
// 浏览器不支持或异常,默认直接停止
|
|
|
this.recordObj.status = "0";
|
|
|
+ this.recordObj.loading = false;
|
|
|
let iframe = this.$refs["iframeRef"];
|
|
|
iframe.contentWindow.onSessionStopped = null;
|
|
|
iframe.contentWindow.window.onRecognizedResult = null;
|