|
@@ -665,10 +665,13 @@ export const onEnded = () => {
|
|
|
};
|
|
|
|
|
|
// 根据当前小节动态设置,右上角展示的速度
|
|
|
-const dynamicShowPlaySpeed = (index: number) => {
|
|
|
+const dynamicShowPlaySpeed = (index: number, isPlaying?: boolean) => {
|
|
|
if (!headerColumnHide.value) {
|
|
|
- // console.log('动态计算速度')
|
|
|
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)
|
|
@@ -771,7 +774,7 @@ const handlePlaying = () => {
|
|
|
}
|
|
|
}
|
|
|
gotoNext(item);
|
|
|
- dynamicShowPlaySpeed(item.i);
|
|
|
+ dynamicShowPlaySpeed(item.i, true);
|
|
|
}
|
|
|
|
|
|
// 评测不播放叮咚节拍器
|
|
@@ -1055,6 +1058,16 @@ export const gotoNext = (note: any, skipNote?: boolean) => {
|
|
|
state.activeNoteIndex = num;
|
|
|
state.activeMeasureIndex = note.MeasureNumberXML;
|
|
|
osmd.cursor.activeMeasureNum = note.MeasureNumberXML;
|
|
|
+ // 赋值音符id
|
|
|
+ osmd.cursor.noteGraphicalId = state.times[state.activeNoteIndex].id;
|
|
|
+ // 设置光标位置
|
|
|
+ nextTick(() => {
|
|
|
+ if (osmd.cursor.noteGraphicalId) {
|
|
|
+ const { x, y } = document.getElementById(`vf-${osmd.cursor.noteGraphicalId}`)?.getBoundingClientRect() || { x: 0, y: 0}
|
|
|
+ osmd.cursor.cursorElement.style.left = x + "px";
|
|
|
+ // cursorElement.style.top = y + "px";
|
|
|
+ }
|
|
|
+ })
|
|
|
dynamicShowPlaySpeed(state.activeNoteIndex);
|
|
|
if (prev && num - prev === 1) {
|
|
|
// console.log('跳转音符',11111,osmd.cursor)
|
|
@@ -1444,6 +1457,13 @@ const getMusicInfo = async (res: any) => {
|
|
|
} else {
|
|
|
(window as any).DYFirstTrackName = '';
|
|
|
}
|
|
|
+ // 如果是作业模式,需要默认渲染当前学生声部对应的声轨
|
|
|
+ if (state.isHomeWork && storeData.user?.instrumentId) {
|
|
|
+ const currentTrack = res.data.musicSheetSoundList.find((item: any) => item.musicalInstrumentId === storeData.user?.instrumentId)?.track;
|
|
|
+ if (currentTrack) {
|
|
|
+ partIndex = tracks.findIndex(item => item === currentTrack) || partIndex
|
|
|
+ }
|
|
|
+ }
|
|
|
// 设置音源 track 为当前的声轨 index为当前的
|
|
|
const { track, index, musicalInstrumentId } = state.isSimplePage ? { track:tracks[0], index:0, musicalInstrumentId: '' } : initMusicSource(res.data, tracks, partIndex, workRecordInstrumentId)
|
|
|
// 这里返回的track可能和实际的对不上,所以重新筛选一下
|
|
@@ -1481,10 +1501,17 @@ function initMusicSource(data: any, tracks: string[], partIndex: number, workRec
|
|
|
accompanyObj = musicSheetAccompanimentList.find((item: any) => {
|
|
|
return item.audioPlayType === "PLAY"
|
|
|
})
|
|
|
- // 是否全声部(isAllSubject)为true 时候没有乐器只有一个原音(比如节奏练习,这个曲子全部乐器都支持);当前用户有乐器就匹配 不然取第一个原音
|
|
|
- musicObj = musicSheetSoundList.find((item: any) => {
|
|
|
- return isAllSubject ? item.audioPlayType === "PLAY" : (item.audioPlayType === "PLAY" && item.musicalInstrumentId == instrumentId)
|
|
|
- })
|
|
|
+ // 如果specialInstrumentIds有多个,是打击乐的声部,打击乐声部可能有多个乐器id
|
|
|
+ if (storeData.user?.specialInstrumentIds?.length > 1) {
|
|
|
+ musicObj = musicSheetSoundList.find((item: any) => {
|
|
|
+ return isAllSubject ? item.audioPlayType === "PLAY" : (item.audioPlayType === "PLAY" && storeData.user?.specialInstrumentIds?.includes(item.musicalInstrumentId))
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 是否全声部(isAllSubject)为true 时候没有乐器只有一个原音(比如节奏练习,这个曲子全部乐器都支持);当前用户有乐器就匹配 不然取第一个原音
|
|
|
+ musicObj = musicSheetSoundList.find((item: any) => {
|
|
|
+ return isAllSubject ? item.audioPlayType === "PLAY" : (item.audioPlayType === "PLAY" && item.musicalInstrumentId == instrumentId)
|
|
|
+ })
|
|
|
+ }
|
|
|
// 当没有找到原音的时候,并且instrumentId没有值的时候,取默认第一个乐器
|
|
|
if(!musicObj && !instrumentId){
|
|
|
musicObj = musicSheetSoundList.find((item: any) => {
|
|
@@ -2246,7 +2273,7 @@ watch(
|
|
|
}
|
|
|
)
|
|
|
|
|
|
- // 完成拖动弹窗引导页
|
|
|
+// 完成拖动弹窗引导页
|
|
|
export const handleGuide = async () => {
|
|
|
const guideInfoStore = localStorage.getItem('guideInfo') ? JSON.parse(localStorage.getItem('guideInfo')) : {};
|
|
|
guideInfoStore.teacherDrag = true;
|
|
@@ -2256,4 +2283,26 @@ export const handleGuide = async () => {
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
}
|
|
|
-};
|
|
|
+};
|
|
|
+
|
|
|
+export const resetCursorPosition = () => {
|
|
|
+ if (metronomeData.cursorMode === 1) {
|
|
|
+ const currentActive = document.querySelector(`.dotActive`);
|
|
|
+ currentActive?.classList.remove('dotActive');
|
|
|
+ const currentDot = document.querySelector(`.noteIndex_${state.activeNoteIndex}`)
|
|
|
+ if (currentDot) {
|
|
|
+ currentDot.classList.add('dotActive')
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const currentActive = document.querySelector(`.dotActive`);
|
|
|
+ currentActive?.classList.remove('dotActive');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => state.activeNoteIndex,
|
|
|
+ () => {
|
|
|
+ resetCursorPosition();
|
|
|
+ }
|
|
|
+);
|