add play/pause toggle shortcut key, #898
This commit is contained in:
parent
58b4e22df4
commit
a82e4b1c51
@ -150,6 +150,7 @@ const VideoPlayer = ({
|
||||
const resetPlaybackSpeedPressed = useKeyPress('=');
|
||||
const arrowRightPressed = useKeyPress('ArrowRight');
|
||||
const arrowLeftPressed = useKeyPress('ArrowLeft');
|
||||
const pPausedPressed = useKeyPress('p');
|
||||
|
||||
const videoId = video.youtube_id;
|
||||
const videoUrl = video.media_url;
|
||||
@ -214,6 +215,16 @@ const VideoPlayer = ({
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [mutePressed]);
|
||||
|
||||
useEffect(() => {
|
||||
if (pPausedPressed) {
|
||||
if (videoRef.current?.paused) {
|
||||
videoRef.current.play();
|
||||
} else {
|
||||
videoRef.current?.pause();
|
||||
}
|
||||
}
|
||||
}, [pPausedPressed]);
|
||||
|
||||
useEffect(() => {
|
||||
if (increasePlaybackSpeedPressed) {
|
||||
const newSpeed = playbackSpeedIndex + 1;
|
||||
@ -400,6 +411,10 @@ const VideoPlayer = ({
|
||||
<td>Show help</td>
|
||||
<td>?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Toggle pause play</td>
|
||||
<td>p</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Toggle mute</td>
|
||||
<td>m</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user