瀏覽代碼

feat: 一行谱页面修改

TIANYONG 1 年之前
父節點
當前提交
46accf5d91
共有 2 個文件被更改,包括 16 次插入5 次删除
  1. 15 4
      src/page-instrument/simple-detail/index.tsx
  2. 1 1
      src/state.ts

+ 15 - 4
src/page-instrument/simple-detail/index.tsx

@@ -8,7 +8,7 @@ import store from "store";
 import { formateTimes } from "../../helpers/formateMusic";
 import { setCustomGradual, setCustomNoteRealValue } from "/src/helpers/customMusicScore"
 import { initSmoothAnimation, smoothAnimationState, destroySmoothAnimation, moveSmoothAnimationByPlayTime } from "../view-detail/smoothAnimation";
-import { api_playProgress } from "/src/helpers/communication";
+import { api_playProgress, api_cloudLoading } from "/src/helpers/communication";
 
 export default defineComponent({
 	name: "simple-detail",
@@ -29,10 +29,19 @@ export default defineComponent({
 				state.playState = 'play';
 				setStep();
 			}
+			// 暂停播放
 			if (res?.data?.api === "api_paused") {
 				console.log('暂停播放')
 				state.playState = 'paused';
 			}
+			// 暂停状态下,拖动进度
+			if (res?.data?.api === "api_updateProgress") {
+				console.log('拖动的进度')
+				if (state.playState === 'paused') {
+					detailData.currentTime = res?.data?.data ? res?.data?.data : detailData.currentTime;
+					handlePlaying();
+				}
+			}
 			// 播放进度
 			if (res?.data?.api === "api_playProgress") {
 				if (res?.data.data) {
@@ -89,8 +98,8 @@ export default defineComponent({
 			// 一行谱创建 动画
 			initSmoothAnimation();
 			//destroySmoothAnimation();
-			smoothAnimationState.isShow.value = false;
-			state.playState = 'play';
+			//smoothAnimationState.isShow.value = false;
+			api_cloudLoading();
 			console.log('渲染完成',svgHeight)
 			window.parent.postMessage(
 				{
@@ -99,19 +108,21 @@ export default defineComponent({
 				},
 				"*"
 			);			
+			// state.playState = 'play';
 			// setStep();
 		};
 		/**
 		 * 播放一直触发的事件
 		 */
 		const handlePlaying = () => {
+			//detailData.currentTime += 0.03
 			const currentTime = detailData.currentTime;
 			// console.log('👀~播放进度',currentTime)
 			let item = getNote(currentTime);
 			if (item) {
 				gotoNext(item);
 			}
-			state.activeNoteIndex = item.i
+			state.activeNoteIndex = item?.i || 0
 			// 一行谱,需要滚动小节
 			if (state.isSingleLine) {
 				moveSmoothAnimationByPlayTime(currentTime)

+ 1 - 1
src/state.ts

@@ -1295,7 +1295,7 @@ const setState = (data: any, index: number) => {
   state.detailId = data.bizId;
   state.xmlUrl = data.xmlFileUrl;
   state.paymentType = data.paymentType
-  state.partIndex = index;
+  state.partIndex = index >= 0 ? index : 0;
   state.trackId = data.track;
   state.subjectId = data.subjectIds ? data.subjectIds.split(',')?.[0] : 0;
   // 声部code