Kaynağa Gözat

feat: 非C调时,只有谱面类型是首调时,才能播放唱名

TIANYONG 6 ay önce
ebeveyn
işleme
8bea0747fc

+ 6 - 0
src/helpers/formateMusic.ts

@@ -640,6 +640,12 @@ export const formatXML = (xml: string, xmlUrl?: string): string => {
 	
 	const xmlParse = new DOMParser().parseFromString(xml, "text/xml");
 
+	// 声调
+	const fifths = xmlParse.getElementsByTagName("fifths");
+	if (fifths && fifths.length) {
+		// 是否是C调
+		state.isCTone = fifths[0].textContent === '0'
+	}
 	const measures = Array.from(xmlParse.getElementsByTagName("measure"));
 	const minutes: any = xmlParse.getElementsByTagName("per-minute");
 	let speeds: any = []

+ 16 - 2
src/page-instrument/header-top/index.tsx

@@ -9,7 +9,7 @@ import { Badge, Circle, Popover, Popup, showConfirmDialog, showToast, NoticeBar
 import Speed from "./speed";
 import { evaluatingData, handleStartEvaluat } from "/src/view/evaluating";
 import Settting from "./settting";
-import state, { IPlatform, handleChangeSection, handleResetPlay, handleRessetState, togglePlay, IPlayState, refreshMusicSvg } from "/src/state";
+import state, { IPlatform, handleChangeSection, handleResetPlay, handleRessetState, togglePlay, IPlayState, refreshMusicSvg, EnumMusicRenderType } from "/src/state";
 import { getAudioCurrentTime } from "/src/view/audio-list";
 import { followData, toggleFollow } from "/src/view/follow-practice";
 import { api_back } from "/src/helpers/communication";
@@ -905,7 +905,21 @@ export default defineComponent({
             playBtn.value.disabled && styles.disabled,
             state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.playLeftButton : state.platform === IPlatform.PC && state.musicScoreBtnDirection === "right" ? styles.playRightButton : "",
           ]}
-          onClick={() => togglePlay(state.playState === "play" ? "paused" : "play")}
+          onClick={() => {
+            // C调能播放唱名,非C调时,只有谱面类型是首调时,才能播放唱名
+            if (!state.isCTone && state.playSource === 'mingSong') {
+              const notPlayDesc = state.musicRenderType === EnumMusicRenderType.staff ? '该曲目的五线谱目前还不支持播放唱名' : state.musicRenderType === EnumMusicRenderType.fixedTone ? '该曲目的固定调目前还不支持播放唱名' : '';
+              if (notPlayDesc) {
+                showToast({
+                  message: notPlayDesc,
+                  position: "top",
+                  className: "selectionToast",
+                });
+                return
+              }
+            }
+            togglePlay(state.playState === "play" ? "paused" : "play")
+          }}
         >
           <div class={styles.btnWrap}>
             <img style={{ display: state.playState === "play" ? "none" : "" }} class={styles.iconBtn} src={headImg("icon_play.png")} />

+ 2 - 0
src/state.ts

@@ -560,6 +560,8 @@ const state = reactive({
   workSectionNeedReset: false,
   /** 旋律线开关 */
   melodyLine: true,
+  /** 是否是C调,切换到唱名时,只有C调所有的谱面类型都可以播放唱名文件;其它调的只有首调可以播放唱名,因为唱名是按照C调制作的,没有其它调的唱名文件 */
+  isCTone: false,
 });
 const browserInfo = browser();
 let offset_duration = 0;