mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-20 16:22:04 +00:00
fix: restore missing imports and add safe require for immersive mode in usePlayerSetup
This commit is contained in:
parent
b77d681b41
commit
764b4cccf2
1 changed files with 24 additions and 5 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import { StatusBar, Platform, Dimensions, AppState } from 'react-native';
|
import { StatusBar, Platform, Dimensions, AppState } from 'react-native';
|
||||||
import RNImmersiveMode from 'react-native-immersive-mode';
|
|
||||||
import * as NavigationBar from 'expo-navigation-bar';
|
import * as NavigationBar from 'expo-navigation-bar';
|
||||||
import * as Brightness from 'expo-brightness';
|
import * as Brightness from 'expo-brightness';
|
||||||
import { activateKeepAwakeAsync, deactivateKeepAwake } from 'expo-keep-awake';
|
import { activateKeepAwakeAsync, deactivateKeepAwake } from 'expo-keep-awake';
|
||||||
|
|
@ -8,6 +7,16 @@ import { logger } from '../../../../utils/logger';
|
||||||
import { useFocusEffect } from '@react-navigation/native';
|
import { useFocusEffect } from '@react-navigation/native';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
|
// Optional Android immersive mode module
|
||||||
|
let RNImmersiveMode: any = null;
|
||||||
|
if (Platform.OS === 'android') {
|
||||||
|
try {
|
||||||
|
RNImmersiveMode = require('react-native-immersive-mode').default;
|
||||||
|
} catch {
|
||||||
|
RNImmersiveMode = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const DEBUG_MODE = false;
|
const DEBUG_MODE = false;
|
||||||
|
|
||||||
export const usePlayerSetup = (
|
export const usePlayerSetup = (
|
||||||
|
|
@ -36,8 +45,14 @@ export const usePlayerSetup = (
|
||||||
const enableImmersiveMode = async () => {
|
const enableImmersiveMode = async () => {
|
||||||
if (Platform.OS === 'android') {
|
if (Platform.OS === 'android') {
|
||||||
// Standard immersive mode
|
// Standard immersive mode
|
||||||
RNImmersiveMode.setBarTranslucent(true);
|
if (RNImmersiveMode) {
|
||||||
RNImmersiveMode.fullLayout(true);
|
try {
|
||||||
|
RNImmersiveMode.setBarTranslucent(true);
|
||||||
|
RNImmersiveMode.fullLayout(true);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('[usePlayerSetup] RNImmersiveMode failed:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
StatusBar.setHidden(true, 'none');
|
StatusBar.setHidden(true, 'none');
|
||||||
|
|
||||||
// Explicitly hide bottom navigation bar using Expo
|
// Explicitly hide bottom navigation bar using Expo
|
||||||
|
|
@ -52,8 +67,12 @@ export const usePlayerSetup = (
|
||||||
|
|
||||||
const disableImmersiveMode = async () => {
|
const disableImmersiveMode = async () => {
|
||||||
if (Platform.OS === 'android') {
|
if (Platform.OS === 'android') {
|
||||||
RNImmersiveMode.setBarTranslucent(false);
|
if (RNImmersiveMode) {
|
||||||
RNImmersiveMode.fullLayout(false);
|
try {
|
||||||
|
RNImmersiveMode.setBarTranslucent(false);
|
||||||
|
RNImmersiveMode.fullLayout(false);
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
StatusBar.setHidden(false, 'fade');
|
StatusBar.setHidden(false, 'fade');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue