diff --git a/mobile/App.js b/mobile/App.js
index e73924a..d62dc7c 100644
--- a/mobile/App.js
+++ b/mobile/App.js
@@ -1,5 +1,5 @@
-import React, { useEffect, useState } from 'react';
-import { View, StatusBar } from 'react-native';
+import React, { useEffect, useState, Component } from 'react';
+import { View, StatusBar, Text, ScrollView } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
@@ -19,6 +19,30 @@ import LoginScreen from './src/screens/Login';
import NowPlayingScreen from './src/screens/NowPlaying';
import PlayerBar from './src/components/PlayerBar';
+// ─── ERROR BOUNDARY ───
+class ErrorBoundary extends Component {
+ state = { error: null };
+ static getDerivedStateFromError(e) { return { error: e }; }
+ render() {
+ if (this.state.error) {
+ return (
+
+
+ Fehler beim Starten
+
+
+ {this.state.error?.message || String(this.state.error)}
+
+
+ {this.state.error?.stack}
+
+
+ );
+ }
+ return this.props.children;
+ }
+}
+
const Tab = createBottomTabNavigator();
const Stack = createStackNavigator();
@@ -63,11 +87,16 @@ function RootNavigator() {
export default function App() {
const { loadConfig } = useStore();
const [ready, setReady] = useState(false);
+ const [initError, setInitError] = useState(null);
useEffect(() => {
(async () => {
- await loadConfig();
- await setupPlayer();
+ try {
+ await loadConfig();
+ await setupPlayer();
+ } catch (e) {
+ setInitError(e?.message || String(e));
+ }
setReady(true);
})();
}, []);
@@ -82,26 +111,37 @@ export default function App() {
return () => { sub1.remove(); sub2.remove(); };
}, []);
- if (!ready) return null;
+ if (!ready) return (
+
+ );
+
+ if (initError) return (
+
+ Init-Fehler
+ {initError}
+
+ );
return (
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
);
}
diff --git a/mobile/src/audio/player.js b/mobile/src/audio/player.js
index 8c5eac0..a665f69 100644
--- a/mobile/src/audio/player.js
+++ b/mobile/src/audio/player.js
@@ -6,25 +6,23 @@ let _setupDone = false;
export async function setupPlayer() {
if (_setupDone) return;
- await TrackPlayer.setupPlayer({ autoHandleInterruptions: true });
- await TrackPlayer.updateOptions({
- capabilities: [
- Capability.Play,
- Capability.Pause,
- Capability.SkipToNext,
- Capability.SkipToPrevious,
- Capability.SeekTo,
- Capability.Stop,
- ],
- compactCapabilities: [Capability.Play, Capability.Pause, Capability.SkipToNext, Capability.SkipToPrevious],
- notificationCapabilities: [
- Capability.Play,
- Capability.Pause,
- Capability.SkipToNext,
- Capability.SkipToPrevious,
- ],
- });
- _setupDone = true;
+ try {
+ await TrackPlayer.setupPlayer();
+ await TrackPlayer.updateOptions({
+ capabilities: [
+ Capability.Play,
+ Capability.Pause,
+ Capability.SkipToNext,
+ Capability.SkipToPrevious,
+ Capability.SeekTo,
+ Capability.Stop,
+ ],
+ compactCapabilities: [Capability.Play, Capability.Pause, Capability.SkipToNext, Capability.SkipToPrevious],
+ });
+ _setupDone = true;
+ } catch (e) {
+ console.error('TrackPlayer setup failed:', e);
+ }
}
// Convert a Navidrome song object to a react-native-track-player track object