Browse Source

处理原音反显问题

yuanliang 1 year ago
parent
commit
847d8cbd52
1 changed files with 37 additions and 30 deletions
  1. 37 30
      src/views/music-library/music-sheet/modal/music-operationV2.tsx

+ 37 - 30
src/views/music-library/music-sheet/modal/music-operationV2.tsx

@@ -1106,35 +1106,40 @@ export default defineComponent({
 
               const existSoundList = data.musicSheetSoundList ? data.musicSheetSoundList : []
               // 如果只有一个原音文件,并且原音没有对应声轨,取xml解析中的第一个声轨绑定当当前原音
-              if (existSoundList.length === 1 && !formatTrack(existSoundList[0].track)) {
-                let track = state.partListNames.length > 0 ? state.partListNames[0].value : null;
-                forms.musicSheetSoundList_YY.push({
-                  audioFileUrl: existSoundList[0].audioFileUrl, // 原音
-                  musicalInstrumentId: existSoundList[0].musicalInstrumentId,
-                  track: track, // 轨道
-                  audioPlayType: 'PLAY'
-                })
-                if (track && !forms.multiTracksSelection.includes(track)) {
-                  forms.multiTracksSelection.push(track)
-                }
-              } else {
+              // if (existSoundList.length === 1 && !formatTrack(existSoundList[0].track)) {
+              //   let track = state.partListNames.length > 0 ? state.partListNames[0].value : null;
+              //   forms.musicSheetSoundList_YY.push({
+              //     audioFileUrl: existSoundList[0].audioFileUrl, // 原音
+              //     musicalInstrumentId: existSoundList[0].musicalInstrumentId,
+              //     track: track, // 轨道
+              //     audioPlayType: 'PLAY'
+              //   })
+              //   if (track && !forms.multiTracksSelection.includes(track)) {
+              //     forms.multiTracksSelection.push(track)
+              //   }
+              // } else {
                 const tracks = [] as any
                 state.partListNames.forEach((item: any) => {
                   let audioFileUrl = null
                   let musicalInstrumentId = null
-                  existSoundList.forEach((next: any) => {
-                    if (!next.track || next.track.trim() == '') {
-                      next.track = ''
-                    }
-                    if (next.track == item.value) {
-                      audioFileUrl = next.audioFileUrl
-                      musicalInstrumentId = next.musicalInstrumentId
-                    }
-                  })
+                  if (forms.musicSheetType == 'CONCERT') {
+                    existSoundList.forEach((next: any) => {
+                      if (next.audioPlayType == 'PLAY') {
+                        if (!next.track || next.track.trim() == '') {
+                          next.track = ''
+                        }
+                        if (next.track == item.value) {
+                          audioFileUrl = next.audioFileUrl
+                          musicalInstrumentId = next.musicalInstrumentId
+                        }
+                      }
+                    })
+                  }
                   forms.musicSheetSoundList_YY.push({
                     audioFileUrl: audioFileUrl, // 原音
                     musicalInstrumentId: musicalInstrumentId, // 乐器
-                    track: item.value // 轨道
+                    track: item.value, // 轨道
+                    audioPlayType: 'PLAY'
                   })
                   tracks.push(item.value)
                 })
@@ -1146,16 +1151,18 @@ export default defineComponent({
                 // 处理没有声轨,但有原音
                 if (data.musicSheetType == 'CONCERT') {
                   state.musicSheetSoundList.forEach((next: any) => {
-                    if (next.track && !tracks.includes(next.track.trim()) && next.audioPlayType == 'PLAY') {
-                      forms.musicSheetSoundList_YY.push({
-                        audioFileUrl: next.audioFileUrl, // 原音
-                        musicalInstrumentId: next.musicalInstrumentId,
-                        track: next.track ? next.track.trim() : '', // 轨道
-                        audioPlayType: 'PLAY'
-                      })
+                    if (next.audioPlayType == 'PLAY') {
+                      if (next.track && !tracks.includes(next.track.trim()) && next.audioPlayType == 'PLAY') {
+                        forms.musicSheetSoundList_YY.push({
+                          audioFileUrl: next.audioFileUrl, // 原音
+                          musicalInstrumentId: next.musicalInstrumentId,
+                          track: next.track ? next.track.trim() : '', // 轨道
+                          audioPlayType: 'PLAY'
+                        })
+                      }
                     }
                   })
-                }
+                // }
               }
             }
           })