diff --git a/App.tsx b/App.tsx index d90ca6e3..e576beba 100644 --- a/App.tsx +++ b/App.tsx @@ -11,6 +11,7 @@ import { ONE_DAY, queryClient } from './src/constants/query-client' import { GestureHandlerRootView } from 'react-native-gesture-handler' import TrackPlayer, { AndroidAudioContentType, + AppKilledPlaybackBehavior, IOSCategory, IOSCategoryOptions, } from 'react-native-track-player' @@ -63,6 +64,11 @@ export default function App(): React.JSX.Element { notificationCapabilities: CAPABILITIES, // Reduced interval for smoother progress tracking and earlier prefetch detection progressUpdateEventInterval: PROGRESS_UPDATE_EVENT_INTERVAL, + // Stop playback and remove notification when app is killed to prevent battery drain + android: { + appKilledPlaybackBehavior: + AppKilledPlaybackBehavior.StopPlaybackAndRemoveNotification, + }, }), ) .finally(() => { diff --git a/jest/setup/rntp.ts b/jest/setup/rntp.ts index 195b9dcf..2809c92a 100644 --- a/jest/setup/rntp.ts +++ b/jest/setup/rntp.ts @@ -55,6 +55,9 @@ jest.mock('react-native-track-player', () => { useTrackPlayerEvents: (events: Event[], handler: (variables: any) => void) => { eventHandler = handler }, + AppKilledPlaybackBehavior: { + StopPlaybackAndRemoveNotification: 'stopPlaybackAndRemoveNotification', + }, Capability: { Play: 1, PlayFromId: 2,