浏览代码

唱名文件和演唱文件时间差距比较大的时候,设置时间不能同步设置

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

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

@@ -119,9 +119,11 @@ export const setAudioCurrentTime = (time: number, index = 0) => {
 		setMidiCurrentTime(index);
 		return;
 	}
+	if(state.playSource === "mingSong") {
+		audioData.mingSongEle && (audioData.mingSongEle.currentTime = time);
+	}
 	audioData.songEle && (audioData.songEle.currentTime = time);
 	audioData.backgroundEle && (audioData.backgroundEle.currentTime = time);
-	audioData.mingSongEle && (audioData.mingSongEle.currentTime = time);
 	audioData.progress = time;
 };
 
@@ -168,7 +170,10 @@ export const changeSongSourceByBate = (isDisBate:boolean) => {
 	}
 	audioData.songEle && (audioData.songEle.currentTime = currentTime)
 	audioData.backgroundEle && (audioData.backgroundEle.currentTime = currentTime)
-	audioData.mingSongEle && (audioData.mingSongEle.currentTime = currentTime)
+	// 当前是唱名才设置时间
+	if(state.playSource === "mingSong") {
+		audioData.mingSongEle && (audioData.mingSongEle.currentTime = currentTime)
+	}
 	// 设置静音与取消静音
 	if (state.playSource === "music") {
 		audioData.songEle && (audioData.songEle.muted = false);