SanHQin il y a 10 mois
Parent
commit
deb06a0a6d
1 fichiers modifiés avec 28 ajouts et 16 suppressions
  1. 28 16
      src/components/pages/classroomObservation/components/chatArea.vue

+ 28 - 16
src/components/pages/classroomObservation/components/chatArea.vue

@@ -830,27 +830,39 @@ export default {
 		// this.TapeNum = 0;
 		// },
 		async finishRecorded() {
-			let iiframe = this.$refs["iiframe"];
-			iiframe.contentWindow.window.document
-				.getElementById("scenarioStopButton")
-				.click();
-			// 录音借宿
-			iiframe.contentWindow.onSessionStopped = (s, e) => {
-				this.recordedForm.status = 3;
-				this.controlsStatus = 2;
-				this.$message.success("已结束录音");
-				clearInterval(this.recordedForm.timer);
-				console.log("结束录音👇");
-				console.log("结束录音", e);
-				this.recordedForm.audioBlob.push(e.preaudio);
+			if (this.recordedForm.status == 1) {
+				//正在录音时
+				let iiframe = this.$refs["iiframe"];
+				iiframe.contentWindow.window.document
+					.getElementById("scenarioStopButton")
+					.click();
+				// 录音借宿
+				iiframe.contentWindow.onSessionStopped = (s, e) => {
+					this.recordedForm.status = 3;
+					this.controlsStatus = 2;
+					this.$message.success("已结束录音");
+					clearInterval(this.recordedForm.timer);
+					console.log("结束录音👇");
+					console.log("结束录音", e);
+					this.recordedForm.audioBlob.push(e.preaudio);
+					let blob = new Blob(this.recordedForm.audioBlob, {
+						type: "audio/wav",
+					});
+					let file = new File([blob], "recordedFile.wav", {
+						type: "text/plain",
+					});
+					this.uploadFile(file, { changeText: false, flag: true });
+					iiframe.contentWindow.onSessionStopped = null;
+					iiframe.contentWindow.onRecognizedResult = null;
+				};
+			} else if (this.recordedForm.status == 2) {
+				//暂停录音时
 				let blob = new Blob(this.recordedForm.audioBlob, {
 					type: "audio/wav",
 				});
 				let file = new File([blob], "recordedFile.wav", { type: "text/plain" });
 				this.uploadFile(file, { changeText: false, flag: true });
-				iiframe.contentWindow.onSessionStopped = null;
-				iiframe.contentWindow.onRecognizedResult = null;
-			};
+			}
 
 			// this.uploadFileLoading = true;
 			// recorder.stop();