mirror of
https://github.com/tomru/advcal.git
synced 2026-03-03 14:37:19 +01:00
seek to 0 when revealing
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user