Add files via upload
This commit is contained in:
parent
ddac17c6c5
commit
5f4e59b56b
6 changed files with 29 additions and 27 deletions
3
app.json
3
app.json
|
|
@ -29,7 +29,8 @@
|
||||||
},
|
},
|
||||||
"scheme": "burmalda",
|
"scheme": "burmalda",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"expo-router"
|
"expo-router",
|
||||||
|
"react-native-track-player"
|
||||||
],
|
],
|
||||||
"updates": {
|
"updates": {
|
||||||
"enabled": false
|
"enabled": false
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,9 @@ export default function HomeScreen() {
|
||||||
load();
|
load();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useFocusEffect(() => {
|
useFocusEffect(useCallback(() => {
|
||||||
loadDownloadedTracks();
|
loadDownloadedTracks();
|
||||||
});
|
}, [loadDownloadedTracks]));
|
||||||
|
|
||||||
const onRefresh = async () => {
|
const onRefresh = async () => {
|
||||||
setRefresh(true);
|
setRefresh(true);
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,7 @@ import { StatusBar } from 'expo-status-bar';
|
||||||
import { useBootAuth } from '../hooks/useAuth';
|
import { useBootAuth } from '../hooks/useAuth';
|
||||||
import { Colors } from '../constants/theme';
|
import { Colors } from '../constants/theme';
|
||||||
|
|
||||||
export default function RootLayout() {
|
// Must be defined before use — hooks are not hoisted
|
||||||
useBootAuth();
|
|
||||||
useOTAUpdates();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<GestureHandlerRootView style={{ flex: 1, backgroundColor: Colors.bg }}>
|
|
||||||
<StatusBar style="light" />
|
|
||||||
<Stack screenOptions={{ headerShown: false, contentStyle: { backgroundColor: Colors.bg } }}>
|
|
||||||
<Stack.Screen name="(tabs)" />
|
|
||||||
<Stack.Screen name="auth" options={{ presentation: 'fullScreenModal' }} />
|
|
||||||
</Stack>
|
|
||||||
</GestureHandlerRootView>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function useOTAUpdates() {
|
function useOTAUpdates() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (__DEV__) return;
|
if (__DEV__) return;
|
||||||
|
|
@ -38,3 +24,18 @@ function useOTAUpdates() {
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function RootLayout() {
|
||||||
|
useBootAuth();
|
||||||
|
useOTAUpdates();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<GestureHandlerRootView style={{ flex: 1, backgroundColor: Colors.bg }}>
|
||||||
|
<StatusBar style="light" />
|
||||||
|
<Stack screenOptions={{ headerShown: false, contentStyle: { backgroundColor: Colors.bg } }}>
|
||||||
|
<Stack.Screen name="(tabs)" />
|
||||||
|
<Stack.Screen name="auth" options={{ presentation: 'fullScreenModal' }} />
|
||||||
|
</Stack>
|
||||||
|
</GestureHandlerRootView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,11 @@ let _lastLoadedId: number | null = null;
|
||||||
|
|
||||||
async function ensureSetup() {
|
async function ensureSetup() {
|
||||||
if (_setupDone) return;
|
if (_setupDone) return;
|
||||||
_setupDone = true;
|
|
||||||
try {
|
try {
|
||||||
await TrackPlayer.setupPlayer({
|
await TrackPlayer.setupPlayer({
|
||||||
minBuffer: 15,
|
minBuffer: 15,
|
||||||
maxBuffer: 50,
|
maxBuffer: 50,
|
||||||
playBuffer: 2.5,
|
playBuffer: 2.5,
|
||||||
// iOS: show full artwork on lock screen
|
|
||||||
iosCategory: 'playback' as any,
|
|
||||||
iosCategoryMode: 'default' as any,
|
|
||||||
});
|
});
|
||||||
await TrackPlayer.updateOptions({
|
await TrackPlayer.updateOptions({
|
||||||
android: {
|
android: {
|
||||||
|
|
@ -42,7 +38,6 @@ async function ensureSetup() {
|
||||||
Capability.Pause,
|
Capability.Pause,
|
||||||
Capability.SkipToNext,
|
Capability.SkipToNext,
|
||||||
],
|
],
|
||||||
// iOS lock screen: larger artwork
|
|
||||||
notificationCapabilities: [
|
notificationCapabilities: [
|
||||||
Capability.Play,
|
Capability.Play,
|
||||||
Capability.Pause,
|
Capability.Pause,
|
||||||
|
|
@ -51,12 +46,14 @@ async function ensureSetup() {
|
||||||
Capability.SeekTo,
|
Capability.SeekTo,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
_setupDone = true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
// "already" means player was set up before (e.g. hot reload)
|
||||||
if (e?.message?.toLowerCase().includes('already')) {
|
if (e?.message?.toLowerCase().includes('already')) {
|
||||||
_setupDone = true;
|
_setupDone = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_setupDone = false;
|
// Other errors — allow retry next call
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
7
index.js
7
index.js
|
|
@ -3,9 +3,12 @@ import 'expo-router/entry';
|
||||||
// Register TrackPlayer background service safely
|
// Register TrackPlayer background service safely
|
||||||
// Must be wrapped — if native module isn't ready, app would white-screen otherwise
|
// Must be wrapped — if native module isn't ready, app would white-screen otherwise
|
||||||
try {
|
try {
|
||||||
const TrackPlayer = require('react-native-track-player').default;
|
const TP = require('react-native-track-player');
|
||||||
|
const TrackPlayer = TP.default ?? TP;
|
||||||
const { PlaybackService } = require('./hooks/PlaybackService');
|
const { PlaybackService } = require('./hooks/PlaybackService');
|
||||||
TrackPlayer.registerPlaybackService(() => PlaybackService);
|
if (TrackPlayer?.registerPlaybackService && typeof PlaybackService === 'function') {
|
||||||
|
TrackPlayer.registerPlaybackService(() => PlaybackService);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// TrackPlayer native module not ready yet — skip service registration
|
// TrackPlayer native module not ready yet — skip service registration
|
||||||
// Music playback via TrackPlayer will still work, just no remote controls
|
// Music playback via TrackPlayer will still work, just no remote controls
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
"expo-image": "~1.12.15",
|
"expo-image": "~1.12.15",
|
||||||
"expo-linear-gradient": "~13.0.2",
|
"expo-linear-gradient": "~13.0.2",
|
||||||
"expo-linking": "~6.3.1",
|
"expo-linking": "~6.3.1",
|
||||||
"expo-network": "^55.0.13",
|
"expo-network": "~4.0.0",
|
||||||
"expo-router": "~3.5.23",
|
"expo-router": "~3.5.23",
|
||||||
"expo-secure-store": "~13.0.2",
|
"expo-secure-store": "~13.0.2",
|
||||||
"expo-status-bar": "~1.12.1",
|
"expo-status-bar": "~1.12.1",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue