From 12ae61695d46bd7a3ffca67bfd3c14b0cae6db6e Mon Sep 17 00:00:00 2001 From: Jordan Mele Date: Sun, 6 Oct 2024 09:08:14 +0000 Subject: [PATCH 1/2] Option to keep display on when fullscreen --- .../blueskyvideo/BlueskyVideoModule.kt | 4 +-- .../modules/blueskyvideo/BlueskyVideoView.kt | 3 ++- .../blueskyvideo/FullscreenActivity.kt | 6 +++++ example/App.tsx | 26 ++++++++++++++----- ios/BlueskyVideoModule.swift | 4 +-- ios/VideoView.swift | 10 ++++++- src/BlueskyVideoView.tsx | 4 +-- 7 files changed, 43 insertions(+), 14 deletions(-) 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() { From e7ee2982112d635af11d966324ca81dca041bc3d Mon Sep 17 00:00:00 2001 From: Hailey Date: Mon, 7 Oct 2024 11:31:33 -0700 Subject: [PATCH 2/2] 0.2.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e907b1d..3ce1f7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bluesky-video", - "version": "0.1.10", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bluesky-video", - "version": "0.1.10", + "version": "0.2.0", "license": "MIT", "devDependencies": { "@types/react": "^18.0.25", diff --git a/package.json b/package.json index c137bf0..fc4d954 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@haileyok/bluesky-video", - "version": "0.1.10", + "version": "0.2.0", "description": "A video player library for Bluesky", "main": "build/index.js", "types": "build/index.d.ts",