fix: 播放按钮状态延迟到 audio.play() resolve 后再设置,避免提前显示暂停图标
This commit is contained in:
@@ -523,9 +523,12 @@ export default function VoiceMaterialLibrary() {
|
||||
setPlayingId(null);
|
||||
const audio = new Audio(m.sourceUrl);
|
||||
audio.onended = () => setPlayingId(null);
|
||||
audio.play().catch(() => setPlayingId(null));
|
||||
audioRef.current = audio;
|
||||
setPlayingId(m.id);
|
||||
audio.play().then(() => {
|
||||
setPlayingId(m.id);
|
||||
}).catch(() => {
|
||||
setPlayingId(null);
|
||||
});
|
||||
}
|
||||
}}
|
||||
title={playingId === m.id ? '暂停' : '播放'}
|
||||
|
||||
Reference in New Issue
Block a user