-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathservice.js
24 lines (23 loc) · 867 Bytes
/
service.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import TrackPlayer, {TrackPlayerEvents} from 'react-native-track-player';
module.exports = async function () {
// This service needs to be registered for the module to work
// but it will be used later in the "Receiving Events" section
TrackPlayer.addEventListener(TrackPlayerEvents.REMOTE_PLAY, () =>
TrackPlayer.play(),
);
TrackPlayer.addEventListener(TrackPlayerEvents.REMOTE_PAUSE, () =>
TrackPlayer.pause(),
);
TrackPlayer.addEventListener(TrackPlayerEvents.REMOTE_NEXT, () =>
TrackPlayer.skipToNext(),
);
TrackPlayer.addEventListener(TrackPlayerEvents.REMOTE_STOP, () =>
TrackPlayer.skipToPrevious(),
);
TrackPlayer.addEventListener(TrackPlayerEvents.REMOTE_STOP, () =>
TrackPlayer.destroy(),
);
TrackPlayer.addEventListener(TrackPlayerEvents.REMOTE_SEEK, ({position}) =>
TrackPlayer.seekTo(position),
);
};