This commit is contained in:
an-lee
2024-07-17 09:39:42 +08:00
parent 8ec2e5dfc4
commit 9bb7133fb7
4 changed files with 5 additions and 13 deletions

View File

@@ -22,7 +22,7 @@ export const SpeechPlayer = (props: {
const [initialized, setInitialized] = useState(false);
const onPlayClick = useCallback(() => {
wavesurfer.isPlaying() ? wavesurfer.pause() : wavesurfer.play();
wavesurfer.playPause();
}, [wavesurfer]);
useEffect(() => {

View File

@@ -67,11 +67,7 @@ export const MediaPlayerControls = () => {
const playOrPause = () => {
if (!wavesurfer) return;
if (wavesurfer.isPlaying()) {
wavesurfer.pause();
} else {
wavesurfer.play();
}
wavesurfer.playPause();
};
const debouncedPlayOrPause = debounce(playOrPause, 100);

View File

@@ -46,7 +46,7 @@ export const WavesurferPlayer = (props: {
const onPlayClick = useCallback(() => {
if (!wavesurfer) return;
wavesurfer.isPlaying() ? wavesurfer.pause() : wavesurfer.play();
wavesurfer.playPause();
}, [wavesurfer]);
const initialize = () => {

View File

@@ -34,7 +34,7 @@ export const RecordingPlayer = (props: {
const [initialized, setInitialized] = useState(false);
const onPlayClick = useCallback(() => {
wavesurfer.isPlaying() ? wavesurfer.pause() : wavesurfer.play();
wavesurfer.playPause();
}, [wavesurfer]);
useEffect(() => {
@@ -107,11 +107,7 @@ export const RecordingPlayer = (props: {
useEffect(() => {
if (!wavesurfer) return;
if (isPlaying) {
wavesurfer.play();
} else {
wavesurfer.pause();
}
wavesurfer.playPause();
}, [isPlaying, wavesurfer]);
return (