浏览代码

解决没有演奏文件,默认跳到演唱模式,跳转播放进度的问题

黄琪勇 11 月之前
父节点
当前提交
011cf6bf02
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      src/view/audio-list/index.tsx

+ 7 - 3
src/view/audio-list/index.tsx

@@ -135,9 +135,13 @@ export const toggleMutePlayAudio = (source: IPlayState, muted: boolean) => {
 /** 切换节拍器音源 */
 export const changeSongSourceByBate = (isDisBate:boolean) => {
 	// isDisBate 为true 切换到不带节拍的,为false 切换到带节拍的
-	const songEleCurrentTime = audioData.songEle?.currentTime || 0
-	const backgroundEleCurrentTime = audioData.backgroundEle?.currentTime || 0
-	const mingSongEleCurrentTime = audioData.mingSongEle?.currentTime || 0
+	let songEleCurrentTime = audioData.songEle?.currentTime || 0
+	let backgroundEleCurrentTime = audioData.backgroundEle?.currentTime || 0
+	let mingSongEleCurrentTime = audioData.mingSongEle?.currentTime || 0
+	// 有一种场景,默认模式没有文件内容的时候,songEle,backgroundEle,mingSongEle都为空,在设置音源之前点击跳转位置,这时候以audioData.progress的时间为准
+	if(!audioData.songEle&&!audioData.backgroundEle&&!audioData.mingSongEle){
+		songEleCurrentTime = backgroundEleCurrentTime = mingSongEleCurrentTime = audioData.progress || 0
+	}
 	if (isDisBate) {
 		if(state.playType === "play"){
 			audioData.songEle = audioData.songCollection.songEle