use of guichaguri.trackplayer.logic.track.Track in project react-native-track-player by react-native-kit.
the class Playback method updateCurrentTrack.
protected void updateCurrentTrack(int track, Promise callback) {
if (queue.isEmpty()) {
reset();
Utils.rejectCallback(callback, "queue", "The queue is empty");
return;
} else if (track >= queue.size()) {
track = queue.size() - 1;
} else if (track < 0) {
track = 0;
}
Track previous = getCurrentTrack();
long position = getPosition();
int oldState = getState();
Log.d(Utils.TAG, "Updating current track...");
Track next = queue.get(track);
currentTrack = track;
load(next, callback);
if (Utils.isPlaying(oldState)) {
play();
} else if (Utils.isPaused(oldState)) {
pause();
}
manager.onTrackUpdate(previous, position, next, true);
}
Aggregations