use of guichaguri.trackplayer.logic.track.Track in project react-native-track-player by react-native-kit.
the class MediaManager method onPlay.
public void onPlay() {
Log.d(Utils.TAG, "onPlay: The service is now on foreground, audio focus, wake and wifi locks have been acquired");
MediaNotification notification = metadata.getNotification();
// Set the service as foreground, updating and showing the notification
service.startForeground(MediaNotification.NOTIFICATION_ID, notification.build());
notification.setShowing(true);
// Activate the session
metadata.setEnabled(true);
if (!playback.isRemote()) {
// Enable the audio focus so the device knows we are playing music
focus.enable();
// Acquire the wake lock so the device doesn't sleeps stopping the music
if (!wakeLock.isHeld())
wakeLock.acquire();
Track currentTrack = playback.getCurrentTrack();
if (currentTrack != null && !currentTrack.urlLocal) {
// Acquire wifi lock when the track needs network
if (!wifiLock.isHeld())
wifiLock.acquire();
}
}
if (!serviceStarted) {
Log.d(Utils.TAG, "Marking the service as started, as there is now playback");
service.startService(new Intent(service, PlayerService.class));
serviceStarted = true;
}
}
use of guichaguri.trackplayer.logic.track.Track in project react-native-track-player by react-native-kit.
the class MediaWrapper method getTrack.
public void getTrack(final String id, final Promise callback) {
Playback pb = manager.getPlayback();
if (checkPlayback(pb, callback))
return;
for (Track track : pb.getQueue()) {
if (track.id.equals(id)) {
Utils.resolveCallback(callback, Arguments.fromBundle(track.toBundle()));
return;
}
}
Utils.rejectCallback(callback, "track", "No track found");
}
use of guichaguri.trackplayer.logic.track.Track in project react-native-track-player by react-native-kit.
the class Playback method onEnd.
protected void onEnd() {
Track previous = getCurrentTrack();
long position = getPosition();
manager.onEnd(previous, position);
}
use of guichaguri.trackplayer.logic.track.Track in project react-native-track-player by react-native-kit.
the class Playback method reset.
public void reset() {
Track prev = getCurrentTrack();
long pos = getPosition();
queue.clear();
manager.onQueueUpdate();
currentTrack = -1;
manager.onTrackUpdate(prev, pos, null, true);
}
use of guichaguri.trackplayer.logic.track.Track in project react-native-track-player by react-native-kit.
the class Playback method remove.
public void remove(List<String> ids, Promise callback) {
ListIterator<Track> i = queue.listIterator();
int currTrack = currentTrack;
while (i.hasNext()) {
int index = i.nextIndex();
Track track = i.next();
for (String id : ids) {
if (track.id.equals(id)) {
i.remove();
if (currTrack == index) {
currTrack = i.nextIndex();
}
break;
}
}
}
if (currTrack != currentTrack) {
updateCurrentTrack(currTrack, null);
}
Utils.resolveCallback(callback);
manager.onQueueUpdate();
}
Aggregations