|
@@ -84,7 +84,9 @@ export default {
|
|
|
recordObj: {
|
|
recordObj: {
|
|
|
status: "0", // 0:默认 1:录音中 2:暂停,
|
|
status: "0", // 0:默认 1:录音中 2:暂停,
|
|
|
loading:false,
|
|
loading:false,
|
|
|
|
|
+ startTime:0, // 开始录音时间
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
@@ -141,23 +143,51 @@ export default {
|
|
|
|
|
|
|
|
iframe.contentWindow.ConversationTranscriber();
|
|
iframe.contentWindow.ConversationTranscriber();
|
|
|
this.recordObj.status = "1"
|
|
this.recordObj.status = "1"
|
|
|
|
|
+ this.recordObj.startTime = new Date().getTime();
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
stopRecord() {
|
|
stopRecord() {
|
|
|
- if(this.recordObj.status=='1' && !this.recordObj.loading){
|
|
|
|
|
- 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"
|
|
|
|
|
|
|
+ console.log()
|
|
|
|
|
+ if(this.recordObj.startTime!==0 && 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;
|
|
this.recordObj.loading = false;
|
|
|
- this.$message.success("已停止录音")
|
|
|
|
|
|
|
+ let iframe = this.$refs["iframeRef"];
|
|
|
iframe.contentWindow.onSessionStopped = null;
|
|
iframe.contentWindow.onSessionStopped = null;
|
|
|
iframe.contentWindow.window.onRecognizedResult = null;
|
|
iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ this.$message.success("未开启录音权限,已停止录音");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 有权限再判断状态
|
|
|
|
|
+ if(this.recordObj.status=='1' && !this.recordObj.loading){
|
|
|
|
|
+ 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;
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ // 浏览器不支持或异常,默认直接停止
|
|
|
|
|
+ this.recordObj.status = "0";
|
|
|
|
|
+ this.recordObj.loading = false;
|
|
|
|
|
+ let iframe = this.$refs["iframeRef"];
|
|
|
|
|
+ iframe.contentWindow.onSessionStopped = null;
|
|
|
|
|
+ iframe.contentWindow.window.onRecognizedResult = null;
|
|
|
|
|
+ this.$message.success("无法检测麦克风权限,已停止录音");
|
|
|
|
|
+ });
|
|
|
// this.recordObj.status = "0"
|
|
// this.recordObj.status = "0"
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|