fix: 录音中 暂停语音播放
This commit is contained in:
@@ -17,11 +17,13 @@ function Index(props: DefinedProps) {
|
||||
const [isPlaying, setIsPlating] = useState(false);
|
||||
const [currentPlayingId, setCurrentPlayingId] = useState<number>();
|
||||
|
||||
// useEffect(() => {
|
||||
// if (isRecording) {
|
||||
// stopAllAudio();
|
||||
// }
|
||||
// }, [isRecording]);
|
||||
useEffect(() => {
|
||||
if (isRecording && currentPlayingId) {
|
||||
audioRefs.current[currentPlayingId].pause();
|
||||
audioRefs.current[currentPlayingId].currentTime = 0;
|
||||
setCurrentPlayingId(undefined);
|
||||
}
|
||||
}, [isRecording, currentPlayingId]);
|
||||
|
||||
const playAudio = (id: number, audioUrl: string) => {
|
||||
if (isRecording) {
|
||||
@@ -45,22 +47,7 @@ function Index(props: DefinedProps) {
|
||||
setCurrentPlayingId(undefined);
|
||||
}
|
||||
};
|
||||
// const stopAllAudio = () => {
|
||||
// if (currentPlayingId && audioRefs.current[currentPlayingId]) {
|
||||
// audioRefs.current[currentPlayingId].pause();
|
||||
// audioRefs.current[currentPlayingId].currentTime = 0;
|
||||
// setIsPlating(false);
|
||||
// setCurrentPlayingId(undefined);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Object.values(audioRefs.current).forEach((audio) => {
|
||||
// if (!audio.paused) {
|
||||
// audio.pause();
|
||||
// audio.currentTime = 0;
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
const renderAvatar = (item: Message) => {
|
||||
return <Avatar src={item.petAvatar || ""} style={{ "--border-radius": "32px" }} />;
|
||||
};
|
||||
@@ -132,32 +119,6 @@ function Index(props: DefinedProps) {
|
||||
<div className="time">{item.contentDuration}''</div>
|
||||
</div>
|
||||
{renderTranslateResult(item)}
|
||||
{/* {item.isTranslating ? (
|
||||
<div className="translate">
|
||||
<SpinLoading color="default" style={{ "--size": "12px" }} />
|
||||
<span>翻译中...</span>
|
||||
</div>
|
||||
) : item.transStatus === 1 ? (
|
||||
<div className="translate">
|
||||
{item.transResult?.length ? (
|
||||
item.transResult
|
||||
) : (
|
||||
<Space justify={"between"}>
|
||||
<span>未知语句</span>
|
||||
<Refresh onClick={(e) => refreshMessage(item.id, e)} size="12" fill="#333" />
|
||||
</Space>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<Space justify={"between"} className="translate">
|
||||
<span>翻译失败,请重试</span>
|
||||
<Refresh onClick={(e) => refreshMessage(item.id, e)} size="12" fill="#333" />
|
||||
</Space>
|
||||
// <div className="translate">
|
||||
// <span> 翻译失败,请重试</span>
|
||||
// <Refresh onClick={(e) => refreshMessage(item.id, e)} size="12" fill="#333" />
|
||||
// </div>
|
||||
)} */}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user