fix: start app, even if setting up player fails
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
import { ColorSchemeProvider, themes, useUserOrSystemScheme } from './Colors';
|
import { ColorSchemeProvider, themes, useUserOrSystemScheme } from './Colors';
|
||||||
import DownloadManager from './DownloadManager';
|
import DownloadManager from './DownloadManager';
|
||||||
import AppLoading from './AppLoading';
|
import AppLoading from './AppLoading';
|
||||||
|
import { captureException } from '@sentry/react-native';
|
||||||
|
|
||||||
const LightTheme = {
|
const LightTheme = {
|
||||||
...DefaultTheme,
|
...DefaultTheme,
|
||||||
@@ -52,7 +53,9 @@ export default function App(): JSX.Element | null {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function setupTrackPlayer() {
|
async function setupTrackPlayer() {
|
||||||
await TrackPlayer.setupPlayer({ autoHandleInterruptions: true });
|
await TrackPlayer.setupPlayer({
|
||||||
|
autoHandleInterruptions: true,
|
||||||
|
});
|
||||||
await TrackPlayer.updateOptions({
|
await TrackPlayer.updateOptions({
|
||||||
capabilities: [
|
capabilities: [
|
||||||
Capability.Play,
|
Capability.Play,
|
||||||
@@ -68,7 +71,12 @@ export default function App(): JSX.Element | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hasSetupPlayer) {
|
if (!hasSetupPlayer) {
|
||||||
setupTrackPlayer();
|
setupTrackPlayer()
|
||||||
|
.catch((e: unknown) => {
|
||||||
|
console.error(e);
|
||||||
|
captureException(e);
|
||||||
|
setHasSetupPlayer(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [hasSetupPlayer]);
|
}, [hasSetupPlayer]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user