2018-04-21 21:10:01 +00:00
|
|
|
package org.schabi.newpipe.player.playqueue;
|
2017-09-05 19:27:12 +00:00
|
|
|
|
2023-09-20 13:41:21 +00:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
2017-09-05 19:27:12 +00:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
2017-11-02 05:33:13 +00:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
2017-09-05 19:27:12 +00:00
|
|
|
|
2018-01-17 05:12:03 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2017-09-05 19:27:12 +00:00
|
|
|
|
|
|
|
public final class SinglePlayQueue extends PlayQueue {
|
2017-11-02 05:33:13 +00:00
|
|
|
public SinglePlayQueue(final StreamInfoItem item) {
|
2022-07-15 02:10:29 +00:00
|
|
|
super(0, List.of(new PlayQueueItem(item)));
|
2017-11-02 05:33:13 +00:00
|
|
|
}
|
|
|
|
|
2017-09-25 03:14:58 +00:00
|
|
|
public SinglePlayQueue(final StreamInfo info) {
|
2022-07-15 02:10:29 +00:00
|
|
|
super(0, List.of(new PlayQueueItem(info)));
|
2017-11-02 05:33:13 +00:00
|
|
|
}
|
|
|
|
|
2019-03-13 01:31:03 +00:00
|
|
|
public SinglePlayQueue(final StreamInfo info, final long startPosition) {
|
2022-07-15 02:10:29 +00:00
|
|
|
super(0, List.of(new PlayQueueItem(info)));
|
2019-03-13 01:31:03 +00:00
|
|
|
getItem().setRecoveryPosition(startPosition);
|
|
|
|
}
|
|
|
|
|
2023-09-20 13:41:21 +00:00
|
|
|
public SinglePlayQueue(@NonNull final List<StreamInfoItem> items, final int index) {
|
2018-01-17 05:12:03 +00:00
|
|
|
super(index, playQueueItemsOf(items));
|
|
|
|
}
|
|
|
|
|
2023-09-20 13:41:21 +00:00
|
|
|
private static List<PlayQueueItem> playQueueItemsOf(@NonNull final List<StreamInfoItem> items) {
|
2020-08-16 08:24:58 +00:00
|
|
|
final List<PlayQueueItem> playQueueItems = new ArrayList<>(items.size());
|
2018-01-17 05:12:03 +00:00
|
|
|
for (final StreamInfoItem item : items) {
|
|
|
|
playQueueItems.add(new PlayQueueItem(item));
|
|
|
|
}
|
|
|
|
return playQueueItems;
|
2017-09-05 19:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isComplete() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-03-31 17:20:15 +00:00
|
|
|
public void fetch() {
|
2023-09-20 13:41:21 +00:00
|
|
|
// Item was already passed in constructor.
|
|
|
|
// No further items need to be fetched as this is a PlayQueue with only one item
|
2020-03-31 17:20:15 +00:00
|
|
|
}
|
2017-09-05 19:27:12 +00:00
|
|
|
}
|