Enable background controls for iOS
This commit is contained in:
32
src/utility/PlaybackService.ts
Normal file
32
src/utility/PlaybackService.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* This is the code that will run tied to the player.
|
||||
*
|
||||
* The code here might keep running in the background.
|
||||
*
|
||||
* You should put everything here that should be tied to the playback but not the UI
|
||||
* such as processing media buttons or analytics
|
||||
*/
|
||||
|
||||
import TrackPlayer from 'react-native-track-player';
|
||||
|
||||
export default async function() {
|
||||
TrackPlayer.addEventListener('remote-play', () => {
|
||||
TrackPlayer.play();
|
||||
});
|
||||
|
||||
TrackPlayer.addEventListener('remote-pause', () => {
|
||||
TrackPlayer.pause();
|
||||
});
|
||||
|
||||
TrackPlayer.addEventListener('remote-next', () => {
|
||||
TrackPlayer.skipToNext();
|
||||
});
|
||||
|
||||
TrackPlayer.addEventListener('remote-previous', () => {
|
||||
TrackPlayer.skipToPrevious();
|
||||
});
|
||||
|
||||
TrackPlayer.addEventListener('remote-stop', () => {
|
||||
TrackPlayer.destroy();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user