diff --git a/android/src/main/java/expo/modules/blueskyvideo/BlueskyVideoModule.kt b/android/src/main/java/expo/modules/blueskyvideo/BlueskyVideoModule.kt index 4213c85..699ffce 100644 --- a/android/src/main/java/expo/modules/blueskyvideo/BlueskyVideoModule.kt +++ b/android/src/main/java/expo/modules/blueskyvideo/BlueskyVideoModule.kt @@ -83,8 +83,8 @@ class BlueskyVideoModule : Module() { view.toggleMuted() } - AsyncFunction("enterFullscreen") { view: BlueskyVideoView -> - view.enterFullscreen() + AsyncFunction("enterFullscreen") { view: BlueskyVideoView, keepDisplayOn: Boolean -> + view.enterFullscreen(keepDisplayOn) } } } diff --git a/android/src/main/java/expo/modules/blueskyvideo/BlueskyVideoView.kt b/android/src/main/java/expo/modules/blueskyvideo/BlueskyVideoView.kt index f50220f..8b380c1 100644 --- a/android/src/main/java/expo/modules/blueskyvideo/BlueskyVideoView.kt +++ b/android/src/main/java/expo/modules/blueskyvideo/BlueskyVideoView.kt @@ -229,7 +229,7 @@ class BlueskyVideoView( // Fullscreen handling - fun enterFullscreen() { + fun enterFullscreen(keepDisplayOn: Boolean) { val currentActivity = this.appContext.currentActivity ?: return this.enteredFullscreenMuteState = this.isMuted @@ -246,6 +246,7 @@ class BlueskyVideoView( // create the intent and give it a view val intent = Intent(context, FullscreenActivity::class.java) + intent.putExtra("keepDisplayOn", keepDisplayOn) FullscreenActivity.asscVideoView = WeakReference(this) // fire the fullscreen event and launch the intent diff --git a/android/src/main/java/expo/modules/blueskyvideo/FullscreenActivity.kt b/android/src/main/java/expo/modules/blueskyvideo/FullscreenActivity.kt index 3eba628..09f391a 100644 --- a/android/src/main/java/expo/modules/blueskyvideo/FullscreenActivity.kt +++ b/android/src/main/java/expo/modules/blueskyvideo/FullscreenActivity.kt @@ -30,6 +30,12 @@ class FullscreenActivity : AppCompatActivity() { WindowManager.LayoutParams.FLAG_FULLSCREEN, ) + val keepDisplayOn = this.getIntent().getBooleanExtra("keepDisplayOn", false) + + if (keepDisplayOn) { + this.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + } + // Update the player viewz val playerView = PlayerView(this).apply { diff --git a/example/App.tsx b/example/App.tsx index 8099efe..a10c517 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -7,7 +7,10 @@ import { Platform, Pressable, SafeAreaView, - View + View, + Text, + Switch, + SwitchChangeEvent } from 'react-native' import {SAMPLE_VIDEOS} from './sampleVideos' @@ -17,12 +20,22 @@ export default function App() { return [...SAMPLE_VIDEOS, ...SAMPLE_VIDEOS] }, []) - const renderItem = React.useCallback(({item}: ListRenderItemInfo) => { - return - }, []) + const [fullscreenKeepDisplayOn, setFullscreenKeepDisplayOn] = React.useState(false); + const toggleFullscreenKeepDisplayOn = React.useCallback((event: SwitchChangeEvent) => { + setFullscreenKeepDisplayOn(v => !v); + }, [setFullscreenKeepDisplayOn]); + + const renderItem = React.useCallback(({item, index}: ListRenderItemInfo) => { + return + }, [fullscreenKeepDisplayOn]) return ( + Options + + Keep display on when fullscreen + + (null) const onPress = () => { console.log('press') - ref.current?.enterFullscreen() + ref.current?.enterFullscreen(fullscreenKeepDisplayOn) } return ( + Video: {num} { this.ref.current?.toggleMuted() } - enterFullscreen = () => { - this.ref.current?.enterFullscreen() + enterFullscreen = (keepDisplayOn?: boolean) => { + this.ref.current?.enterFullscreen(keepDisplayOn ?? false) } render() {