Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): keep screen on fullscreen #3563

Merged

Conversation

gkueny
Copy link
Contributor

@gkueny gkueny commented Mar 5, 2024

Summary

add KEEP_SCREEN_ON flag when video is fullscreen & playing to avoid phone to go off.

inspired by expo/expo@2d84661

Motivation

On some Android, phone can go off while video is playing in fullscreen
see #3552

Changes

While we are in fullscreen, we check each 200ms if video is playing or not.

  • If yes we set FLAG_KEEP_SCREEN_ON to fullscreen view
  • If not we remove FLAG_KEEP_SCREEN_ON from fullscreen view

Test plan

yarn add react-native-video@https://github.com/gkueny/react-native-video.git#4963a591ea7f18b8084ff2aac7df10927f2b0c4e
  • run it on an real android device

    • check that if you go fullscreen & video do not play , your phone go off after configured sleep time
    • check that if you go fullscreen & video play , your phone do not go off after configured sleep time
    • check that if you go fullscreen & video play & you stop the video , your phone go off after configured sleep time
  • Update code to set preventsDisplaySleepDuringVideoPlayback to false & run it on an real android device

    • check that if you go fullscreen & video do not play , your phone go off after configured sleep time
    • check that if you go fullscreen & video play , your phone go off after configured sleep time
    • check that if you go fullscreen & video play & you stop the video , your phone go off after configured sleep time

@freeboub
Copy link
Collaborator

freeboub commented Mar 5, 2024

but, it will not work if you go to fullscreen while playback is paused ? btw, in 'normal' exoplayer integration, the flag is removed when the playback is paused...
Please double check following use case:

  • when you pause player, the flag is removed (ie, keepScreenOn is disabled)
  • when you player full screen while you are pause and then start playback, the flag shall be enable once playback is started (ie, keepScreenOn is enable)

Thank you

@gkueny
Copy link
Contributor Author

gkueny commented Mar 6, 2024

@freeboub

btw, in 'normal' exoplayer integration, the flag is removed when the playback is paused...

Yes, that's my understanding and that's how I implement it. When you pause the video in fullscreen, keepScreenOn is removed & screen will go off

Please double check following use case:

  • when you pause player, the flag is removed (ie, keepScreenOn is disabled)
  • when you player full screen while you are pause and then start playback, the flag shall be enable once playback is started (ie, >keepScreenOn is enable)

I double-checked and it works fine.

@gkueny
Copy link
Contributor Author

gkueny commented Mar 21, 2024

@freeboub Did you have time to look this PR ?

if you have any other questions on the fix implemented, let me know.

@freeboub freeboub changed the title fix(android): keep screen on on fullscreen fix(android): keep screen on fullscreen Mar 21, 2024
add KEEP_SCREEN_ON flag when video is fullscreen & playing to avoid phone to go off.
inspired by expo/expo@2d84661
@gkueny gkueny force-pushed the fix/3552-fullscreen-turn-off branch from b357055 to 4963a59 Compare March 22, 2024 08:04
@freeboub
Copy link
Collaborator

Thank you for the quick integration ! let's merge now !

@freeboub freeboub merged commit bfb76e6 into TheWidlarzGroup:master Mar 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants