Search in sources :

Example 11 with Track

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);
}
Also used : Track(guichaguri.trackplayer.logic.track.Track)

Aggregations

Track (guichaguri.trackplayer.logic.track.Track)11 Playback (guichaguri.trackplayer.player.Playback)3 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 QueueItem (android.support.v4.media.session.MediaSessionCompat.QueueItem)1 PlayerService (guichaguri.trackplayer.logic.services.PlayerService)1 MediaNotification (guichaguri.trackplayer.metadata.components.MediaNotification)1