فهرست منبع

修复midi播放过程中 播放暂停问题

黄琪勇 11 ماه پیش
والد
کامیت
51a5ecc95e
2فایلهای تغییر یافته به همراه7 افزوده شده و 5 حذف شده
  1. 1 1
      src/page-instrument/header-top/index.tsx
  2. 6 4
      src/state.ts

+ 1 - 1
src/page-instrument/header-top/index.tsx

@@ -826,7 +826,7 @@ export default defineComponent({
             playBtn.value.disabled && styles.disabled,
             state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.playLeftButton : state.platform === IPlatform.PC && state.musicScoreBtnDirection === "right" ? styles.playRightButton : "",
           ]}
-          onClick={() => togglePlay()}
+          onClick={() => togglePlay(state.playState === "play" ? "paused" : "play")}
         >
           <div class={styles.btnWrap}>
             <img style={{ display: state.playState === "play" ? "none" : "" }} class={styles.iconBtn} src={headImg("icon_play.png")} />

+ 6 - 4
src/state.ts

@@ -759,16 +759,16 @@ export const skipNotePlay = async (itemIndex: number, isStart = false) => {
 
 /**
  * 切换曲谱播放状态
- * @param playState 可选: 默认 undefined, 需要切换的状态 play:播放, paused: 暂停
+ * @param playState 需要切换的状态 play:播放, paused: 暂停
  */
-export const togglePlay = async (playState?: "play" | "paused", sourceType?: string) => {
+export const togglePlay = async (playState: "play" | "paused", sourceType?: string) => {
   // 如果mp3资源还在加载中,给出提示
   if (!state.isAppPlay && !state.audioDone) {
     if (sourceType !== 'courseware') showToast('音频资源加载中,请稍后')
     return
   }
   // 播放之前  当为评测模式和不为MIDI时候按  是否禁用节拍器  切换音源
-  if ((playState ? playState : state.playState === "paused" ? "play" : "paused") === 'play' && state.modeType === "practise" && state.playMode !== "MIDI") {
+  if (playState === 'play' && state.modeType === "practise" && state.playMode !== "MIDI") {
     console.log("设置音源")
     changeSongSourceByBate(metronomeData.disable)
   }
@@ -779,6 +779,8 @@ export const togglePlay = async (playState?: "play" | "paused", sourceType?: str
         songID: state.examSongId,
       })
       state.playState = 'paused'
+      // 当在节拍器播放期间暂停的话 就暂停节拍器
+      closeTick()
       return
     }
     skipNotePlay(state.activeNoteIndex, false);
@@ -791,7 +793,7 @@ export const togglePlay = async (playState?: "play" | "paused", sourceType?: str
     const status = cloudGetMediaStatus?.content.status === "suspend" ? "play" : "paused"
     state.playState = status
   } else {
-    state.playState = playState ? playState : state.playState === "paused" ? "play" : "paused";
+    state.playState = playState;
   }
   if (state.playState === "play" && state.sectionStatus && state.section.length == 2 && state.playProgress === 0) {
     resetPlaybackToStart();