fix render of toggle. (#819)
Co-authored-by: Thomas Zarebczan <thomas.zarebczan@gmail.com>
This commit is contained in:
parent
c67893815b
commit
d73504d69c
1 changed files with 18 additions and 2 deletions
|
@ -135,6 +135,16 @@ function VideoViewer(props: Props) {
|
||||||
breaks because some browsers (e.g. Firefox) block autoplay but leave the player.play Promise pending */
|
breaks because some browsers (e.g. Firefox) block autoplay but leave the player.play Promise pending */
|
||||||
const [replay, setReplay] = useState(false);
|
const [replay, setReplay] = useState(false);
|
||||||
const [videoNode, setVideoNode] = useState();
|
const [videoNode, setVideoNode] = useState();
|
||||||
|
const [localAutoplayNext, setLocalAutoplayNext] = useState(autoplayNext);
|
||||||
|
const isFirstRender = React.useRef(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isFirstRender.current) {
|
||||||
|
isFirstRender.current = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toggleAutoplayNext();
|
||||||
|
}, [localAutoplayNext]);
|
||||||
|
|
||||||
const updateVolumeState = React.useCallback(
|
const updateVolumeState = React.useCallback(
|
||||||
debounce((volume, muted) => {
|
debounce((volume, muted) => {
|
||||||
|
@ -325,7 +335,13 @@ function VideoViewer(props: Props) {
|
||||||
addPlayNextButton(player, doPlayNext);
|
addPlayNextButton(player, doPlayNext);
|
||||||
addPlayPreviousButton(player, doPlayPrevious);
|
addPlayPreviousButton(player, doPlayPrevious);
|
||||||
} else {
|
} else {
|
||||||
addAutoplayNextButton(player, toggleAutoplayNext, autoplayNext);
|
addAutoplayNextButton(
|
||||||
|
player,
|
||||||
|
() => {
|
||||||
|
setLocalAutoplayNext((e) => !e);
|
||||||
|
},
|
||||||
|
autoplayNext
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -464,7 +480,7 @@ function VideoViewer(props: Props) {
|
||||||
startMuted={autoplayIfEmbedded}
|
startMuted={autoplayIfEmbedded}
|
||||||
toggleVideoTheaterMode={toggleVideoTheaterMode}
|
toggleVideoTheaterMode={toggleVideoTheaterMode}
|
||||||
autoplay={!embedded || autoplayIfEmbedded}
|
autoplay={!embedded || autoplayIfEmbedded}
|
||||||
autoplaySetting={autoplayNext}
|
autoplaySetting={localAutoplayNext}
|
||||||
claimId={claimId}
|
claimId={claimId}
|
||||||
title={claim && ((claim.value && claim.value.title) || claim.name)}
|
title={claim && ((claim.value && claim.value.title) || claim.name)}
|
||||||
channelName={channelName}
|
channelName={channelName}
|
||||||
|
|
Loading…
Reference in a new issue