2020-06-16 21:41:02 +02:00
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
|
2021-12-31 15:04:37 +01:00
|
|
|
import TrackPlayer, { Event } from 'react-native-track-player';
|
2020-06-16 21:41:02 +02:00
|
|
|
|
|
|
|
|
export default async function() {
|
2021-12-31 15:04:37 +01:00
|
|
|
TrackPlayer.addEventListener(Event.RemotePlay, () => {
|
2020-06-16 21:41:02 +02:00
|
|
|
TrackPlayer.play();
|
|
|
|
|
});
|
|
|
|
|
|
2021-12-31 15:04:37 +01:00
|
|
|
TrackPlayer.addEventListener(Event.RemotePause, () => {
|
2020-06-16 21:41:02 +02:00
|
|
|
TrackPlayer.pause();
|
|
|
|
|
});
|
|
|
|
|
|
2021-12-31 15:04:37 +01:00
|
|
|
TrackPlayer.addEventListener(Event.RemoteNext, () => {
|
2020-06-16 21:41:02 +02:00
|
|
|
TrackPlayer.skipToNext();
|
|
|
|
|
});
|
|
|
|
|
|
2021-12-31 15:04:37 +01:00
|
|
|
TrackPlayer.addEventListener(Event.RemotePrevious, () => {
|
2020-06-16 21:41:02 +02:00
|
|
|
TrackPlayer.skipToPrevious();
|
|
|
|
|
});
|
|
|
|
|
|
2021-12-31 15:04:37 +01:00
|
|
|
TrackPlayer.addEventListener(Event.RemoteStop, () => {
|
2022-11-12 16:22:39 +01:00
|
|
|
TrackPlayer.reset();
|
2020-06-16 21:41:02 +02:00
|
|
|
});
|
2020-06-17 15:28:21 +02:00
|
|
|
|
2021-12-31 15:04:37 +01:00
|
|
|
TrackPlayer.addEventListener(Event.RemoteSeek, (event) => {
|
2020-06-17 15:28:21 +02:00
|
|
|
TrackPlayer.seekTo(event.position);
|
|
|
|
|
});
|
|
|
|
|
|
2020-06-16 21:41:02 +02:00
|
|
|
}
|