-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 989 Bytes
/
index.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
25
26
27
28
29
30
import { AppRegistry } from "react-native";
import TrackPlayer from "react-native-track-player";
import App from "./src/Containers/App";
import PlayerStore from "./src/Mobx/Player";
import TrackStore from "./src/Mobx/Track";
AppRegistry.registerComponent("Chantons", () => App);
TrackPlayer.registerEventHandler(async data => {
if (data.type === "playback-track-changed") {
if (data.nextTrack) {
const track = await TrackPlayer.getTrack(data.nextTrack);
TrackStore.title = track.title;
TrackStore.artist = track.artist;
TrackStore.artwork = track.artwork;
}
} else if (data.type === "remote-play") {
TrackPlayer.play();
} else if (data.type === "remote-pause") {
TrackPlayer.pause();
} else if (data.type === "remote-next") {
TrackPlayer.skipToNext();
} else if (data.type === "remote-previous") {
TrackPlayer.skipToPrevious();
} else if (data.type === "playback-state") {
PlayerStore.playbackState = data.state;
}
});