Explorar o código

Merge branch 'feature-tianyong-newVersion' of http://git.dayaedu.com/liushengqiang/music-score into hqyDevNewVersion

黄琪勇 hai 1 mes
pai
achega
e1301f4a18
Modificáronse 4 ficheiros con 24 adicións e 9 borrados
  1. 1 1
      osmd-extended
  2. 13 1
      src/helpers/formateMusic.ts
  3. 9 4
      src/state.ts
  4. 1 3
      src/view/plugins/move-music-score/index.tsx

+ 1 - 1
osmd-extended

@@ -1 +1 @@
-Subproject commit a9aa056f79fb3aa710a6586b2064241a6636bc1c
+Subproject commit 4a585d167cdf26911b7aa5358e97e8a3e19ff195

+ 13 - 1
src/helpers/formateMusic.ts

@@ -1390,7 +1390,9 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 			// 	usetime = usetime + state.secondEvXmlBeginTime;
 			// 	relativeTime = relativeTime + state.secondEvXmlBeginTime;
 			// }
-			if (state.isEvxml && nodeDetail.repeatIdx && nodeDetail.i > 0 && nodeDetail.MeasureNumberXML === 1 && nodeDetail.noteId === 0) {
+			// if (state.isEvxml && nodeDetail.repeatIdx && nodeDetail.i > 0 && nodeDetail.MeasureNumberXML === 1 && nodeDetail.noteId === 0) {
+			const firstRepeatNodeId = allNotes.find((item: any) => item.MeasureNumberXML === state.timegapRepeatMeasureIndex)?.noteId || 0;
+			if (state.isEvxml && nodeDetail.repeatIdx && nodeDetail.i > 0 && nodeDetail.MeasureNumberXML === state.timegapRepeatMeasureIndex && nodeDetail.noteId === firstRepeatNodeId) {
 				const currentWaitTime = state.evXmlBeginArr[nodeDetail.repeatIdx] || 0;
 				nodeDetail.time = nodeDetail.time + currentWaitTime;
 				nodeDetail.endtime = nodeDetail.endtime + currentWaitTime;
@@ -1653,6 +1655,16 @@ const analyzeEvxml = (xmlParse: any, xmlUrl?: string) => {
 		const hasTimeGap = state.xmlHasTimeGap = xmlParse.getElementsByTagName("timegap").length > 0;
 		const hasTimes = xmlParse.getElementsByTagName("times").length > 0;
 		if (timeGaps && timeGaps.length && !firstNoteBeginTime) {
+			// 有timegap的曲子,需要找到是从哪一小节开始循环的,默认是从第一节开始循环
+			const startRepeat = Array.from(xmlParse.getElementsByTagName("repeat") || []).filter((item: any) => item?.getAttribute('direction') === 'forward')
+			const firstRepeat: any = startRepeat?.length ? startRepeat[0] : null;
+			if (firstRepeat) {
+				let parentElement = firstRepeat?.parentNode
+				while (parentElement && parentElement.tagName !== 'measure') {
+					parentElement = parentElement.parentNode
+				}
+				state.timegapRepeatMeasureIndex = parentElement?.getAttribute('number') ? Number(parentElement?.getAttribute('number')) : 1;
+			}
 			for (const timeGap of timeGaps) {
 				const num: any = timeGap?.getAttribute('num'), den: any = timeGap?.getAttribute('den');
 				const startTime = num ? 60 / state.originSpeed * num * 4/den : 0;

+ 9 - 4
src/state.ts

@@ -447,6 +447,8 @@ const state = reactive({
   xmlHasTimes: false,  
   /** evxml的曲子是否有timeGap */
   xmlHasTimeGap: false,
+  /** 有timeGap的曲子,是从哪个小节开始循环的,默认从第一小节开始循环 */
+  timegapRepeatMeasureIndex: 1,
   /** 指法信息 */
   fingeringInfo: {} as IFingering,
   /** 滚动容器的ID */
@@ -649,7 +651,7 @@ export const onEnded = () => {
 // 根据当前小节动态设置,右上角展示的速度
 const dynamicShowPlaySpeed = (index: number) => {
   if (!headerColumnHide.value) {
-    console.log('动态计算速度')
+    // console.log('动态计算速度')
     const item: any = state.times[index];
     if (item && item.measureSpeed ) {
       // console.log('速度1',item.measureSpeed)
@@ -1108,9 +1110,12 @@ export const handleResetPlay = () => {
     audioData.progress = 0
   }
   // 如果是作业模式,不还原速度
-  if (!query.workRecord) {
-    resetBaseRate();
-  }
+  /**
+   * #TODO:2024.09.14,业务需求变更,重播不还原用户设置的速度
+   */
+  // if (!query.workRecord) {
+  //   resetBaseRate();
+  // }
   resetPlaybackToStart();
   // 如果是暂停, 直接播放
   togglePlay("play");

+ 1 - 3
src/view/plugins/move-music-score/index.tsx

@@ -541,10 +541,8 @@ export const renderForMoveData = () => {
 							}
 						}
 					}
-					// index = targetIndex + 1
-					// item.id = `text${index}`
 					index = targetIndex
-					item.id = `text${targetIndex}`
+					item.id = moveData.modelList[targetIndex].id
 				}
 				// console.log(66666666,index)
 				if (index > -1) {