Sfoglia il codice sorgente

Merge branch 'hqyDevNewVersion' of http://git.dayaedu.com/liushengqiang/music-score into ktyq-test-new

黄琪勇 1 mese fa
parent
commit
dfa17814d0
3 ha cambiato i file con 12 aggiunte e 7 eliminazioni
  1. 1 1
      src/page-instrument/view-detail/index.tsx
  2. 6 3
      src/state.ts
  3. 5 3
      src/view/tick/index.tsx

+ 1 - 1
src/page-instrument/view-detail/index.tsx

@@ -299,7 +299,7 @@ export default defineComponent({
        * 设置节拍器,跟练需要播放系统节拍器,所以不需要判断needTick状态
        */
       // if (state.needTick) {
-      handleInitTick(osmd?.Sheet?.SheetPlaybackSetting?.Rhythm?.Numerator || 4);
+      handleInitTick(osmd?.Sheet?.SheetPlaybackSetting?.Rhythm?.Numerator || 4, osmd?.Sheet?.SheetPlaybackSetting?.Rhythm?.denominator);
       // }
       // api_cloudLoading();
       // state.playBtnDirection = query.imagePos === 'left' ? 'left' : 'right';

+ 6 - 3
src/state.ts

@@ -1110,9 +1110,12 @@ export const handleResetPlay = () => {
     audioData.progress = 0
   }
   // 如果是作业模式,不还原速度
-  if (!query.workRecord) {
-    resetBaseRate();
-  }
+  /**
+   * #TODO:2024.09.14,业务需求变更,重播不还原用户设置的速度
+   */
+  // if (!query.workRecord) {
+  //   resetBaseRate();
+  // }
   resetPlaybackToStart();
   // 如果是暂停, 直接播放
   togglePlay("play");

+ 5 - 3
src/view/tick/index.tsx

@@ -10,6 +10,7 @@ import tockWav from "/src/assets/tock.mp3";
 
 const tickData = reactive({
 	len: 0,
+	denominator: undefined as undefined | number,
 	reduceLen: 0,
 	tickEnd: false,
 	/** 节拍器时间 */
@@ -95,9 +96,11 @@ const createAudio = (src: string): Promise<HTMLAudioElement | null> => {
 
 /** 设置节拍器
  * @param beat 节拍数
+ * @param denominator 节拍器分母
  */
-export const handleInitTick = (beat: number) => {
+export const handleInitTick = (beat: number, denominator?: number) => {
 	tickData.len = beat;
+	tickData.denominator = denominator;
 	// 节拍器的个数除以2 直到小于等于4为止 
 	while (beat > 4 && beat % 2 === 0) {
         beat = beat / 2;
@@ -111,8 +114,7 @@ export const handleStartTick = async () => {
 	tickData.show = true;
 	tickData.tickEnd = false;
 	tickData.index = 0;
-	// tickData.beatLengthInMilliseconds = (60 / state.speed) * 1000;
-	tickData.beatLengthInMilliseconds = (state.times[0].xmlMp3BeatFixTime * 1000) / tickData.len || (60 / state.speed) * 1000;
+	tickData.beatLengthInMilliseconds = tickData.denominator ? 4 / tickData.denominator * (60 / state.speed) * 1000 : (60 / state.speed) * 1000;
 	for(let i = 0; i <= useLen.value; i++){
 		// 提前结束, 直接放回false
 		if (tickData.tickEnd) return false;