浏览代码

feat: 选段速度逻辑修改

TIANYONG 8 月之前
父节点
当前提交
dc2536b080
共有 3 个文件被更改,包括 4 次插入29 次删除
  1. 1 1
      osmd-extended
  2. 1 14
      src/page-instrument/header-top/speed/index.tsx
  3. 2 14
      src/state.ts

+ 1 - 1
osmd-extended

@@ -1 +1 @@
-Subproject commit dd68ffab2f3f6e194b3886981036f05dcd1de4ca
+Subproject commit 9d0f5875fcb9468ce0eba40b7849cffdb62bf6cc

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

@@ -35,23 +35,10 @@ export default defineComponent({
 			() => speed.value,
 			() => {
 				// handleSetSpeed(speed.value);
-				//console.log('速度123',speed.value)
 				state.speed = Math.floor(speed.value);
 				// handleSetSpeed(speed.value);
 				if (state.playState === 'paused') {
-					let currentItem: any;
-					if (state.section.length === 2 && state.sectionStatus && state.times[state.activeNoteIndex].MeasureNumberXML === state.sectionFirst.MeasureNumberXML) {
-						currentItem = state.section[0]
-					}
-					if (state.section.length === 2 && state.sectionStatus && state.times[state.activeNoteIndex].MeasureNumberXML !== state.sectionFirst.MeasureNumberXML) {
-						currentItem = state.times[state.activeNoteIndex]
-					}
-					// if (state.section.length === 2 && state.sectionStatus && state.times[state.activeNoteIndex].MeasureNumberXML !== state.sectionFirst.MeasureNumberXML) {
-					// 	currentItem = state.times[state.activeNoteIndex]
-					// } else {
-					// 	currentItem = (state.sectionStatus && state.section.length === 2) ? state.section[0] : state.times[state.activeNoteIndex];
-					// }
-					
+					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;
 				}
 			}

+ 2 - 14
src/state.ts

@@ -682,10 +682,6 @@ export const onEnded = () => {
 const dynamicShowPlaySpeed = (index: number, isPlaying?: boolean) => {
   //if (!headerColumnHide.value) {
     const item: any = state.times[index];
-    if (state.sectionFirst && state.section.length === 2 && item.MeasureNumberXML === state.sectionFirst.MeasureNumberXML) {
-      state.speed = Math.floor(state.section[0].measureSpeed * state.basePlayRate) || state.speed
-      return;
-    }
     if (item && item.measureSpeed ) {
       // console.log('速度1',item.measureSpeed)
       const newSpeed = Math.floor(state.basePlayRate * item.measureSpeed)
@@ -704,12 +700,8 @@ export const initSetPlayRate = () => {
     state.isAutoRePlay = false
     return
   }
-  let item: any = (state.sectionStatus && state.section.length === 2) ? state.section[0] : state.times[state.activeNoteIndex];
+  let item: any = (state.sectionStatus && state.section.length === 2) ? state.sectionFirst || state.section[0] : state.times[state.activeNoteIndex];
   console.log('播放状态',state.playState)
-  // 如果是选段,并且不是选段内的第一小节,取当前小节的速度
-  if (state.sectionStatus && state.section.length === 2 && state.times[state.activeNoteIndex].MeasureNumberXML !== state.section[0].MeasureNumberXML && state.times[state.activeNoteIndex].MeasureNumberXML !== state.sectionFirst?.MeasureNumberXML) {
-    item = state.times[state.activeNoteIndex];
-  }
   if (item && item.measureSpeed) {
     const ratio = state.speed / Math.floor(item.measureSpeed)
     // state.audiosInstance?.setSpeed(ratio)
@@ -722,10 +714,6 @@ export const initSetPlayRate = () => {
 export const resetBaseRate = (idx?: number) => {
   const index = idx ? idx : 0;
   let currentItem: any = state.times[index];
-  // 如果是在预备小节点击原速,需要重置为选段第一小节的速度
-  if (state.section.length === 2 && state.sectionFirst && state.sectionFirst.MeasureNumberXML === currentItem.MeasureNumberXML) {
-    currentItem = state.section[0];
-  }
   const currentSpeed = currentItem?.measureSpeed ? currentItem.measureSpeed : state.originSpeed;
   // console.log('速度2',currentSpeed)
   state.speed = currentSpeed
@@ -1354,7 +1342,7 @@ export const hanldeDirectSelection = (list: any[]) => {
   setTimeout(() => {
     state.section = formateSelectMearure(list);
     // 选段完成后,需要根据预报小节的速度,设置右下角显示的速度
-    const currentItem: any = (state.sectionStatus && state.section.length === 2) ? state.section[0] : state.times[state.activeNoteIndex];
+    const currentItem: any = (state.sectionStatus && state.section.length === 2) ? state.sectionFirst || state.section[0] : state.times[state.activeNoteIndex];
     if (currentItem.measureSpeed && query.workRecord === undefined && query.evaluatingRecord === undefined) {
       handleSetSpeed(currentItem.measureSpeed);
     }