瀏覽代碼

feat: midi播放1.6

TIANYONG 1 年之前
父節點
當前提交
85936a0954
共有 4 個文件被更改,包括 12 次插入1 次删除
  1. 3 1
      src/helpers/midiPlay.tsx
  2. 1 0
      src/state.ts
  3. 1 0
      src/view/audio-list/index.tsx
  4. 7 0
      src/view/evaluating/index.tsx

+ 3 - 1
src/helpers/midiPlay.tsx

@@ -86,9 +86,10 @@ export const changeMode = async (val: IMode, type?: string | undefined) => {
  * 切换midi播放状态
  */
 export const cloudToggleState = async (type: "play" | "paused") => {
+  console.log('api','midi状态2')
   const cloudGetMediaStatus = await api_cloudGetMediaStatus();
   const status = cloudGetMediaStatus?.content.status
-  console.log('api','midi状态',status)
+  console.log('api','midi状态3',status)
   if (status === 'init') {
     return
   }
@@ -104,6 +105,7 @@ export const cloudToggleState = async (type: "play" | "paused") => {
     // startCapture()
     onPlay()
   } else {
+    audioData.progress = 0
     await api_cloudSuspend({
       songID: state.examSongId,
     })

+ 1 - 0
src/state.ts

@@ -627,6 +627,7 @@ export const togglePlay = async (playState?: "play" | "paused") => {
       clearSelection();
     }
   }
+  console.log('api','midi状态0')
   audioListStart(state.playState);
   return true;
 };

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

@@ -27,6 +27,7 @@ export const audioListStart = (type: "play" | "paused") => {
 	if (type === "play" && state.originSpeed !== 0) {
 		setAudioPlaybackRate(state.speed / state.originSpeed);
 	}
+	console.log('api','midi状态1',type,audioData.midiRender)
 	// 如果是midi播放
 	if (audioData.midiRender) {
 		// handleTogglePlayMidi(type);

+ 7 - 0
src/view/evaluating/index.tsx

@@ -30,6 +30,7 @@ import {
 	removeSocketStatus,
 	api_disconnectSocket,
 	api_midiMicDelay,
+	api_cloudSetCurrentTime,
 } from "/src/helpers/communication";
 import state, {
 	IPlayState,
@@ -325,6 +326,12 @@ const handleScoreResult = (res?: IPostMessage) => {
 
 /** 开始评测 */
 export const handleStartBegin = async (preTimes?: number) => {
+	if (state.isAppPlay) {
+		await api_cloudSetCurrentTime({
+			currentTime: 0,
+			songID: state.examSongId,
+		})
+	}
 	evaluatingData.isComplete = false;
 	evaluatingData.evaluatings = {};
 	evaluatingData.resultData = {};