Bläddra i källkod

feat: 选段修改

TIANYONG 11 månader sedan
förälder
incheckning
2e91f36138
2 ändrade filer med 7 tillägg och 26 borttagningar
  1. 7 0
      src/state.ts
  2. 0 26
      src/view/audio-list/loading.tsx

+ 7 - 0
src/state.ts

@@ -664,6 +664,8 @@ const handlePlaying = () => {
         // #8698 bug修复
         if (state.modeType === "practise" && state.sectionStatus) {
           onEnded();
+          state.activeNoteIndex = state.sectionFirst ? state.sectionFirst.i : state.section[0].i
+          dynamicShowPlaySpeed(state.activeNoteIndex)
           resetPlaybackToStart();
           return;
         }
@@ -1032,6 +1034,11 @@ export const handleResetPlay = () => {
 export const handleSetSpeed = (speed: number) => {
   // setStorageSpeed(state.examSongId, speed);
   state.speed = speed;
+  // 当前的音符
+  const currentItem: any = (state.sectionStatus && state.section.length === 2) ? state.sectionFirst || state.section[0] : state.times[state.activeNoteIndex];
+  state.basePlayRate = currentItem?.measureSpeed ? state.speed / currentItem.measureSpeed : state.speed / state.originSpeed;
+  const actualRate = state.originAudioPlayRate * state.basePlayRate;
+  console.log('速度设置',speed,'小节计算的倍率',state.basePlayRate,'实际播放倍率',actualRate)
 };
 /** 清除选段状态 */
 export const clearSelection = () => {

+ 0 - 26
src/view/audio-list/loading.tsx

@@ -16,32 +16,6 @@ export default defineComponent({
 		},
 	},
    setup(props) {
-      function fakeLoadingProgress(duration = 2000, callback: (num: number) => void) {
-         let startTime = Date.now()
-         let progress = 0
-         const timer = setInterval(() => {
-            let timePassed = Date.now() - startTime
-            if (timePassed >= duration) {
-               clearInterval(timer)
-               callback(96) // 进度完成
-               return
-            }
-            progress = Math.min(100, (timePassed / duration) * 100)
-            callback(progress)
-         }, 300)
-      }
-      const loadingProress = ref(0)
-      fakeLoadingProgress(2000, num => {
-         loadingProress.value = num
-      })
-      watch(
-         () => state.audioDone,
-         () => {
-           if (!state.audioDone) {
-            loadingProress.value = 0
-           }
-         }
-       );
       return () =>
          !state.audioDone && (
             <div class={styles.loadingPop}>