|
@@ -15,9 +15,10 @@ import { getMusicSheetDetail } from "./utils/baseApi"
|
|
|
import { getQuery } from "/src/utils/queryString";
|
|
|
import { followData } from "/src/view/follow-practice/index"
|
|
|
import { changeSongSourceByBate } from "/src/view/audio-list"
|
|
|
-import { moveSmoothAnimation, smoothAnimationState, moveSmoothAnimationByPlayTime} from "/src/page-instrument/view-detail/smoothAnimation"
|
|
|
+import { moveSmoothAnimation, smoothAnimationState, moveSmoothAnimationByPlayTime, moveTranslateXNum, destroySmoothAnimation} from "/src/page-instrument/view-detail/smoothAnimation"
|
|
|
import { storeData } from "/src/store";
|
|
|
import { downloadXmlStr } from "./view/music-score"
|
|
|
+import { musicScoreRef } from "/src/page-instrument/view-detail/index"
|
|
|
|
|
|
const query: any = getQuery();
|
|
|
|
|
@@ -499,6 +500,8 @@ const state = reactive({
|
|
|
musicComposer: '',
|
|
|
/** 作词家 */
|
|
|
musicLyricist: '',
|
|
|
+ /** 加载中的文案 */
|
|
|
+ loadingText: '音频资源加载中,请稍后…',
|
|
|
});
|
|
|
const browserInfo = browser();
|
|
|
let offset_duration = 0;
|
|
@@ -895,6 +898,7 @@ export const gotoNext = (note: any, skipNote?: boolean) => {
|
|
|
console.log(error);
|
|
|
}
|
|
|
// 重置 或者切换演奏演唱的时候 可能出现 state.activeNoteIndex === note.i的情况 执行
|
|
|
+ fillWordColor();
|
|
|
if (state.isSingleLine && state.playState === "paused") {
|
|
|
moveSvgDom(skipNote);
|
|
|
}
|
|
@@ -928,6 +932,7 @@ export const gotoNext = (note: any, skipNote?: boolean) => {
|
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
|
}
|
|
|
+ fillWordColor();
|
|
|
// 一行谱,需要滚动小节
|
|
|
if (state.isSingleLine) {
|
|
|
moveSvgDom(skipNote);
|
|
@@ -1126,7 +1131,7 @@ export const hanldeDirectSelection = (list: any[]) => {
|
|
|
setTimeout(() => {
|
|
|
state.section = formateSelectMearure(list);
|
|
|
console.log('选段小节', state.section)
|
|
|
- }, 500);
|
|
|
+ }, 0);
|
|
|
};
|
|
|
let offsetTop = 0;
|
|
|
/**
|
|
@@ -1519,8 +1524,8 @@ export const addNoteBBox = (list: any[]) => {
|
|
|
|
|
|
}
|
|
|
|
|
|
-/** 跳动svgdom */
|
|
|
-export const moveSvgDom = (skipNote?: boolean) => {
|
|
|
+// 给歌词和音符添加动态颜色
|
|
|
+const fillWordColor = () => {
|
|
|
// console.log('当前音符',state.activeNoteIndex)
|
|
|
state.times.forEach((item: any, idx: number) => {
|
|
|
const svgEl = document.getElementById(`vf-${state.times[idx]?.svgElement?.attrs?.id}`)
|
|
@@ -1545,8 +1550,11 @@ export const moveSvgDom = (skipNote?: boolean) => {
|
|
|
if (index === currentNote.repeatIdx) {
|
|
|
lyric?.classList.add('lyricActive')
|
|
|
}
|
|
|
- })
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
+/** 跳动svgdom */
|
|
|
+export const moveSvgDom = (skipNote?: boolean) => {
|
|
|
/**
|
|
|
* 计算需要移动的距离
|
|
|
* 当前选中的音符和第一个音符之间的间距
|
|
@@ -1563,18 +1571,138 @@ export const moveSvgDom = (skipNote?: boolean) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+// 暂停的时候 恢复一行谱偏移位置信息
|
|
|
+watch(
|
|
|
+ () => state.playState,
|
|
|
+ () => {
|
|
|
+ if(state.isSingleLine){
|
|
|
+ // 当在播放中暂停 执行这个方法
|
|
|
+ if(!state.playEnd && state.playState === "paused") {
|
|
|
+ moveTranslateXNum(0)
|
|
|
+ const scrollLeft = smoothAnimationState.osdmScrollDom!.scrollLeft
|
|
|
+ smoothAnimationState.osdmScrollDom!.scrollLeft = scrollLeft + smoothAnimationState.translateXNum
|
|
|
+ smoothAnimationState.translateXNum = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
+/* 根据当前的小节获取前面有多少需要去除的合并小节 */
|
|
|
+function getNeedReduceMultipleRestNum(currMeasureIndex:number){
|
|
|
+ let needReduceMultipleRestNum = 0;
|
|
|
+ for(let noteIndex = 0; noteIndex < state.times.length; noteIndex++){
|
|
|
+ const note = state.times[noteIndex];
|
|
|
+ if (note.MeasureNumberXML > currMeasureIndex) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (note.multipleRestMeasures && note.multipleRestMeasures > 1) {
|
|
|
+ needReduceMultipleRestNum += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return needReduceMultipleRestNum
|
|
|
+}
|
|
|
+
|
|
|
watch(
|
|
|
() => state.activeMeasureIndex,
|
|
|
() => {
|
|
|
- console.log('当前小节',state.activeMeasureIndex)
|
|
|
+ // 需要减去的合并小节数
|
|
|
+ const needReduceMultipleRestNum = getNeedReduceMultipleRestNum(state.activeMeasureIndex)
|
|
|
+ const matchMeasureNum = state.activeMeasureIndex - needReduceMultipleRestNum - 1
|
|
|
+ console.log('选中的小节',matchMeasureNum,'需要减去的小节',needReduceMultipleRestNum,'当前的小节',state.activeMeasureIndex)
|
|
|
state.vfmeasures.forEach((item: any, idx: number) => {
|
|
|
- if (idx === (state.activeMeasureIndex-1)) {
|
|
|
+ if (idx === matchMeasureNum) {
|
|
|
item.querySelector('.vf-custom-bg')?.setAttribute("fill", "#132D4C")
|
|
|
item.querySelector('.vf-custom-bot')?.setAttribute("fill", "#040D1E")
|
|
|
} else {
|
|
|
- item.querySelector('.vf-custom-bg')?.setAttribute("fill", "#609FCF")
|
|
|
- item.querySelector('.vf-custom-bot')?.setAttribute("fill", "#2B70A5")
|
|
|
+ // 有选段只清除选段处的
|
|
|
+ if(state.section.length === 2){
|
|
|
+ // 把中间置灰
|
|
|
+ let leftMeasureNumberXML = state.section[0].MeasureNumberXML
|
|
|
+ let rightMeasureNumberXML = state.section[1].MeasureNumberXML
|
|
|
+ if(leftMeasureNumberXML > rightMeasureNumberXML){
|
|
|
+ leftMeasureNumberXML = state.section[1].MeasureNumberXML
|
|
|
+ rightMeasureNumberXML = state.section[0].MeasureNumberXML
|
|
|
+ }
|
|
|
+ const leftVfmeasuresIndex = leftMeasureNumberXML - getNeedReduceMultipleRestNum(leftMeasureNumberXML) - 1
|
|
|
+ const rightVfmeasuresIndex = rightMeasureNumberXML - getNeedReduceMultipleRestNum(rightMeasureNumberXML) - 1
|
|
|
+ if(idx >= leftVfmeasuresIndex && idx <= rightVfmeasuresIndex){
|
|
|
+ item.querySelector('.vf-custom-bg')?.setAttribute("fill", "#609FCF")
|
|
|
+ item.querySelector('.vf-custom-bot')?.setAttribute("fill", "#2B70A5")
|
|
|
+ }
|
|
|
+ // 预备小节
|
|
|
+ if(state.sectionFirst){
|
|
|
+ const sectionFirstVfmeasuresIndex = state.sectionFirst.MeasureNumberXML - getNeedReduceMultipleRestNum(state.sectionFirst.MeasureNumberXML) - 1
|
|
|
+ const sectionFirstDom = state.vfmeasures[sectionFirstVfmeasuresIndex]
|
|
|
+ sectionFirstDom?.querySelector('.vf-custom-bg')?.setAttribute("fill", "#71B8BD")
|
|
|
+ sectionFirstDom?.querySelector('.vf-custom-bot')?.setAttribute("fill", "#448F9C")
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ item.querySelector('.vf-custom-bg')?.setAttribute("fill", "#609FCF")
|
|
|
+ item.querySelector('.vf-custom-bot')?.setAttribute("fill", "#2B70A5")
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-);
|
|
|
+);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => state.section,
|
|
|
+ () => {
|
|
|
+ if(state.section.length === 2){
|
|
|
+ // 把前面和 后面置灰
|
|
|
+ let leftMeasureNumberXML = state.section[0].MeasureNumberXML
|
|
|
+ let rightMeasureNumberXML = state.section[1].MeasureNumberXML
|
|
|
+ if(leftMeasureNumberXML > rightMeasureNumberXML){
|
|
|
+ leftMeasureNumberXML = state.section[1].MeasureNumberXML
|
|
|
+ rightMeasureNumberXML = state.section[0].MeasureNumberXML
|
|
|
+ }
|
|
|
+ const leftVfmeasuresIndex = leftMeasureNumberXML - getNeedReduceMultipleRestNum(leftMeasureNumberXML) - 1
|
|
|
+ const rightVfmeasuresIndex = rightMeasureNumberXML - getNeedReduceMultipleRestNum(rightMeasureNumberXML) - 1
|
|
|
+ state.vfmeasures.forEach((item: any, idx: number) => {
|
|
|
+ // 小于选中置灰
|
|
|
+ if (idx < leftVfmeasuresIndex) {
|
|
|
+ item.querySelector('.vf-custom-bg')?.setAttribute("fill", "rgba(96,159,207,0.5)")
|
|
|
+ item.querySelector('.vf-custom-bot')?.setAttribute("fill", "rgba(43,112,165,0.5)")
|
|
|
+ }
|
|
|
+ // 大于选中置灰
|
|
|
+ if(idx > rightVfmeasuresIndex){
|
|
|
+ item.querySelector('.vf-custom-bg')?.setAttribute("fill", "rgba(96,159,207,0.5)")
|
|
|
+ item.querySelector('.vf-custom-bot')?.setAttribute("fill", "rgba(43,112,165,0.5)")
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 预备小节
|
|
|
+ if(state.sectionFirst){
|
|
|
+ const sectionFirstVfmeasuresIndex = state.sectionFirst.MeasureNumberXML - getNeedReduceMultipleRestNum(state.sectionFirst.MeasureNumberXML) - 1
|
|
|
+ const sectionFirstDom = state.vfmeasures[sectionFirstVfmeasuresIndex]
|
|
|
+ sectionFirstDom?.querySelector('.vf-custom-bg')?.setAttribute("fill", "#71B8BD")
|
|
|
+ sectionFirstDom?.querySelector('.vf-custom-bot')?.setAttribute("fill", "#448F9C")
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 恢复选段前
|
|
|
+ const matchMeasureNum = state.activeMeasureIndex - getNeedReduceMultipleRestNum(state.activeMeasureIndex) - 1
|
|
|
+ state.vfmeasures.forEach((item: any, idx: number) => {
|
|
|
+ if (idx === matchMeasureNum) {
|
|
|
+ item.querySelector('.vf-custom-bg')?.setAttribute("fill", "#132D4C")
|
|
|
+ item.querySelector('.vf-custom-bot')?.setAttribute("fill", "#040D1E")
|
|
|
+ } else {
|
|
|
+ item.querySelector('.vf-custom-bg')?.setAttribute("fill", "#609FCF")
|
|
|
+ item.querySelector('.vf-custom-bot')?.setAttribute("fill", "#2B70A5")
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+/** 刷新谱面 */
|
|
|
+export const refreshMusicSvg = () => {
|
|
|
+ state.loadingText = '正在加载中,请稍等…'
|
|
|
+ if(state.isSingleLine){
|
|
|
+ // 销毁旋律线
|
|
|
+ destroySmoothAnimation()
|
|
|
+ }
|
|
|
+ musicScoreRef.value?.refreshMusicScore()
|
|
|
+}
|