seek to 0 when revealing

This commit is contained in:
Thomas Ruoff
2020-11-29 00:28:46 +01:00
parent 0e063abc24
commit 93ab6a1699

View File

@@ -10,12 +10,12 @@ let player;
const Player = ({ hidden }) => {
const [playerState, setPlayerState] = useState(-1);
const { openSong } = useContext(AppContext);
const { openSong: { id, startSeconds = 0, endSeconds = 0 } } = useContext(AppContext);
const onPause = () => player && player.pauseVideo();
const onPlay = () => player && player.playVideo();
const onRestart = () => {
player && player.seekTo(openSong.startSeconds || 0);
player && player.seekTo(hidden ? startSeconds : 0);
player && [PAUSED, ENDED].includes(playerState) && player.playVideo();
};
@@ -29,9 +29,9 @@ const Player = ({ hidden }) => {
});
player.on("stateChange", setState);
player.loadVideoById({
videoId: openSong.id,
startSeconds: openSong.startSeconds,
endSeconds: openSong.endSeconds
videoId: id,
startSeconds: hidden ? startSeconds : 0,
endSeconds: hidden ? endSeconds : undefined,
});
return () => {