Enable background controls for iOS

This commit is contained in:
Lei Nelissen
2020-06-16 21:41:02 +02:00
parent 50dd06a473
commit 2b35362272
7 changed files with 63 additions and 9 deletions

View 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();
});
}