Browse Source

feat: midi播放1.4

TIANYONG 1 year ago
parent
commit
5affa9367c

+ 12 - 0
src/helpers/communication.ts

@@ -69,6 +69,18 @@ export const api_startRecording = (content: any): Promise<IPostMessage | undefin
 	if (!storeData.isApp) return Promise.resolve({} as any);
 	return promisefiyPostMessage({ api: "startRecording", content: content });
 };
+/** 评测开始录音 */
+export const api_startRecordingCb = (content: any, callback: CallBack) => {
+	postMessage(
+		{
+			api: "startRecording",
+			content,
+		},
+		callback
+	);
+};
+
+
 /** 评测结束录音 */
 export const api_stopRecording = (): Promise<IPostMessage | undefined> => {
 	if (!storeData.isApp) return Promise.resolve({} as any);

+ 2 - 1
src/helpers/midiPlay.tsx

@@ -85,13 +85,14 @@ export const changeMode = async (val: IMode, type?: string | undefined) => {
 /**
  * 切换midi播放状态
  */
-export const cloudToggleState = async () => {
+export const cloudToggleState = async (type: "play" | "paused") => {
   const cloudGetMediaStatus = await api_cloudGetMediaStatus();
   const status = cloudGetMediaStatus?.content.status
   console.log('api','midi状态',status)
   if (status === 'init') {
     return
   }
+  if (status === 'suspend' && type === 'paused') return
   if (status === 'suspend') {
     await api_cloudPlay({
       songID: state.examSongId,

+ 3 - 1
src/page-instrument/evaluat-model/index.tsx

@@ -249,7 +249,9 @@ export default defineComponent({
     /** 评测结果按钮处理 */
     const handleEvaluatResult = (type: "practise" | "tryagain" | "look" | "share" | "update") => {
       if (type === "update") {
-        if (evaluatingData.resultData?.recordIdStr || evaluatingData.resultData?.recordId) {
+        if (state.isAppPlay) {
+          evaluatModel.evaluatUpdateAudio = true;
+        } else if (evaluatingData.resultData?.recordIdStr || evaluatingData.resultData?.recordId) {
           // 上传云端
           // evaluatModel.evaluatUpdateAudio = true;
           api_openAdjustRecording({

+ 1 - 0
src/state.ts

@@ -924,6 +924,7 @@ export const handleRessetState = () => {
   // 切换模式,清除选段
   skipNotePlay(0, true);
   clearSelection();
+  console.log(2222222)
   if (state.modeType === "evaluating") {
     handleStartEvaluat();
   } else if (state.modeType === "practise") {

+ 1 - 1
src/view/audio-list/index.tsx

@@ -30,7 +30,7 @@ export const audioListStart = (type: "play" | "paused") => {
 	// 如果是midi播放
 	if (audioData.midiRender) {
 		// handleTogglePlayMidi(type);
-		cloudToggleState();
+		cloudToggleState(type);
 		return;
 	}
 	if (type === "play") {

+ 11 - 5
src/view/evaluating/index.tsx

@@ -15,6 +15,7 @@ import {
 	startSoundCheck,
 	api_openWebView,
 	api_startRecording,
+	api_startRecordingCb,
 	api_stopRecording,
 	api_recordStartTime,
 	api_remove_recordStartTime,
@@ -359,13 +360,18 @@ export const handleStartBegin = async (preTimes?: number) => {
 	}
 	if (evaluatingData.isErrorState) return
 	//开始录音
-	await api_startRecording({
+	// await api_startRecording({
+	// 	accompanimentState: state.setting.enableAccompaniment ? 1 : 0,
+	// 	firstNoteTime: preTimes || 0,
+	// });
+	await api_startRecordingCb({
 		accompanimentState: state.setting.enableAccompaniment ? 1 : 0,
 		firstNoteTime: preTimes || 0,
-	});
-	if (state.isAppPlay) {
-		sendOffsetTime(0)
-	}
+	}, () => {
+		if (state.isAppPlay) {
+			sendOffsetTime(0)
+		}
+	})
 	// 如果开启了摄像头, 开启录制视频
 	if (state.setting.camera) {
 		console.log("开始录制视频");