[Video] Disable autoplay option (preview + web player) (#5167)
* rename setting * preview (web) * preview (native) * improve autoplay disabled behaviour on web
This commit is contained in:
parent
d846f5bbf0
commit
60b74f7ab8
4 changed files with 32 additions and 8 deletions
|
|
@ -111,9 +111,9 @@ export function Controls({
|
|||
// autoplay/pause based on visibility
|
||||
const autoplayDisabled = useAutoplayDisabled()
|
||||
useEffect(() => {
|
||||
if (active && !autoplayDisabled) {
|
||||
if (active) {
|
||||
if (onScreen) {
|
||||
play()
|
||||
if (!autoplayDisabled) play()
|
||||
} else {
|
||||
pause()
|
||||
}
|
||||
|
|
@ -151,10 +151,11 @@ export function Controls({
|
|||
const onPressEmptySpace = useCallback(() => {
|
||||
if (!focused) {
|
||||
drawFocus()
|
||||
if (autoplayDisabled) play()
|
||||
} else {
|
||||
togglePlayPause()
|
||||
}
|
||||
}, [togglePlayPause, drawFocus, focused])
|
||||
}, [togglePlayPause, drawFocus, focused, autoplayDisabled, play])
|
||||
|
||||
const onPressPlayPause = useCallback(() => {
|
||||
drawFocus()
|
||||
|
|
@ -240,7 +241,8 @@ export function Controls({
|
|||
}, [])
|
||||
|
||||
const showControls =
|
||||
(focused && !playing) || (interactingViaKeypress ? hasFocus : hovered)
|
||||
((focused || autoplayDisabled) && !playing) ||
|
||||
(interactingViaKeypress ? hasFocus : hovered)
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
@ -273,7 +275,10 @@ export function Controls({
|
|||
? msg`Pause video`
|
||||
: msg`Play video`,
|
||||
)}
|
||||
style={[a.flex_1, web({cursor: showCursor ? 'pointer' : 'none'})]}
|
||||
style={[
|
||||
a.flex_1,
|
||||
web({cursor: showCursor || !playing ? 'pointer' : 'none'}),
|
||||
]}
|
||||
onPress={onPressEmptySpace}
|
||||
/>
|
||||
{!showControls && !focused && duration > 0 && (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue