Search in sources :

Example 6 with PlayQueueItem

use of org.schabi.newpipe.playlist.PlayQueueItem in project NewPipe by TeamNewPipe.

the class PlaylistAppendDialog method fromPlayQueueItems.

public static PlaylistAppendDialog fromPlayQueueItems(final List<PlayQueueItem> items) {
    PlaylistAppendDialog dialog = new PlaylistAppendDialog();
    List<StreamEntity> entities = new ArrayList<>(items.size());
    for (final PlayQueueItem item : items) {
        entities.add(new StreamEntity(item));
    }
    dialog.setInfo(entities);
    return dialog;
}
Also used : PlayQueueItem(org.schabi.newpipe.playlist.PlayQueueItem) ArrayList(java.util.ArrayList) StreamEntity(org.schabi.newpipe.database.stream.model.StreamEntity)

Example 7 with PlayQueueItem

use of org.schabi.newpipe.playlist.PlayQueueItem in project NewPipe by TeamNewPipe.

the class MediaSourceManager method loadImmediate.

private void loadImmediate() {
    if (DEBUG)
        Log.d(TAG, "MediaSource - loadImmediate() called");
    // The current item has higher priority
    final int currentIndex = playQueue.getIndex();
    final PlayQueueItem currentItem = playQueue.getItem(currentIndex);
    if (currentItem == null)
        return;
    // Evict the items being loaded to free up memory
    if (loaderReactor.size() > MAXIMUM_LOADER_SIZE) {
        loaderReactor.clear();
        loadingItems.clear();
    }
    maybeLoadItem(currentItem);
    // The rest are just for seamless playback
    // Although timeline is not updated prior to the current index, these sources are still
    // loaded into the cache for faster retrieval at a potentially later time.
    final int leftBound = Math.max(0, currentIndex - WINDOW_SIZE);
    final int rightLimit = currentIndex + WINDOW_SIZE + 1;
    final int rightBound = Math.min(playQueue.size(), rightLimit);
    final Set<PlayQueueItem> items = new HashSet<>(playQueue.getStreams().subList(leftBound, rightBound));
    // Do a round robin
    final int excess = rightLimit - playQueue.size();
    if (excess >= 0) {
        items.addAll(playQueue.getStreams().subList(0, Math.min(playQueue.size(), excess)));
    }
    items.remove(currentItem);
    for (final PlayQueueItem item : items) {
        maybeLoadItem(item);
    }
}
Also used : PlayQueueItem(org.schabi.newpipe.playlist.PlayQueueItem) HashSet(java.util.HashSet)

Example 8 with PlayQueueItem

use of org.schabi.newpipe.playlist.PlayQueueItem in project NewPipe by TeamNewPipe.

the class MediaSourceManager method isPlaybackReady.

private boolean isPlaybackReady() {
    if (sources.getSize() != playQueue.size())
        return false;
    final ManagedMediaSource mediaSource = (ManagedMediaSource) sources.getMediaSource(playQueue.getIndex());
    final PlayQueueItem playQueueItem = playQueue.getItem();
    return mediaSource.isStreamEqual(playQueueItem);
}
Also used : PlayQueueItem(org.schabi.newpipe.playlist.PlayQueueItem) ManagedMediaSource(org.schabi.newpipe.player.mediasource.ManagedMediaSource)

Aggregations

PlayQueueItem (org.schabi.newpipe.playlist.PlayQueueItem)8 HashSet (java.util.HashSet)3 ManagedMediaSource (org.schabi.newpipe.player.mediasource.ManagedMediaSource)3 Nullable (android.support.annotation.Nullable)2 ArrayList (java.util.ArrayList)2 PlaceholderMediaSource (org.schabi.newpipe.player.mediasource.PlaceholderMediaSource)2 Uri (android.net.Uri)1 NonNull (android.support.annotation.NonNull)1 MediaDescriptionCompat (android.support.v4.media.MediaDescriptionCompat)1 Log (android.util.Log)1 DynamicConcatenatingMediaSource (com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource)1 MediaSource (com.google.android.exoplayer2.source.MediaSource)1 ShuffleOrder (com.google.android.exoplayer2.source.ShuffleOrder)1 Observable (io.reactivex.Observable)1 Single (io.reactivex.Single)1 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Disposable (io.reactivex.disposables.Disposable)1 SerialDisposable (io.reactivex.disposables.SerialDisposable)1 Consumer (io.reactivex.functions.Consumer)1