mirror of
https://github.com/tomru/advcal.git
synced 2026-03-03 06:27:17 +01:00
seek to 0 when revealing
This commit is contained in:
@@ -10,12 +10,12 @@ let player;
|
|||||||
const Player = ({ hidden }) => {
|
const Player = ({ hidden }) => {
|
||||||
const [playerState, setPlayerState] = useState(-1);
|
const [playerState, setPlayerState] = useState(-1);
|
||||||
|
|
||||||
const { openSong } = useContext(AppContext);
|
const { openSong: { id, startSeconds = 0, endSeconds = 0 } } = useContext(AppContext);
|
||||||
|
|
||||||
const onPause = () => player && player.pauseVideo();
|
const onPause = () => player && player.pauseVideo();
|
||||||
const onPlay = () => player && player.playVideo();
|
const onPlay = () => player && player.playVideo();
|
||||||
const onRestart = () => {
|
const onRestart = () => {
|
||||||
player && player.seekTo(openSong.startSeconds || 0);
|
player && player.seekTo(hidden ? startSeconds : 0);
|
||||||
player && [PAUSED, ENDED].includes(playerState) && player.playVideo();
|
player && [PAUSED, ENDED].includes(playerState) && player.playVideo();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,9 +29,9 @@ const Player = ({ hidden }) => {
|
|||||||
});
|
});
|
||||||
player.on("stateChange", setState);
|
player.on("stateChange", setState);
|
||||||
player.loadVideoById({
|
player.loadVideoById({
|
||||||
videoId: openSong.id,
|
videoId: id,
|
||||||
startSeconds: openSong.startSeconds,
|
startSeconds: hidden ? startSeconds : 0,
|
||||||
endSeconds: openSong.endSeconds
|
endSeconds: hidden ? endSeconds : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user