2018-04-21 21:10:01 +00:00
|
|
|
package org.schabi.newpipe.player.playqueue;
|
2017-08-29 00:38:37 +00:00
|
|
|
|
2020-04-15 13:31:53 +00:00
|
|
|
import org.schabi.newpipe.extractor.Page;
|
2017-11-02 06:38:18 +00:00
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
|
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
2018-03-18 15:37:49 +00:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
2017-09-04 17:23:56 +00:00
|
|
|
import org.schabi.newpipe.util.ExtractorHelper;
|
2017-08-29 00:38:37 +00:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2020-10-31 20:55:45 +00:00
|
|
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
|
|
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
2017-08-29 00:38:37 +00:00
|
|
|
|
2017-11-03 03:34:12 +00:00
|
|
|
public final class PlaylistPlayQueue extends AbstractInfoPlayQueue<PlaylistInfo, PlaylistInfoItem> {
|
2017-11-02 06:38:18 +00:00
|
|
|
public PlaylistPlayQueue(final PlaylistInfoItem item) {
|
2017-11-03 03:34:12 +00:00
|
|
|
super(item);
|
2017-11-02 06:38:18 +00:00
|
|
|
}
|
|
|
|
|
2018-01-23 00:40:00 +00:00
|
|
|
public PlaylistPlayQueue(final PlaylistInfo info) {
|
2020-04-15 13:31:53 +00:00
|
|
|
this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0);
|
2018-01-23 00:40:00 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 06:38:18 +00:00
|
|
|
public PlaylistPlayQueue(final int serviceId,
|
2017-11-04 18:30:01 +00:00
|
|
|
final String url,
|
2020-04-15 13:31:53 +00:00
|
|
|
final Page nextPage,
|
2018-03-18 15:37:49 +00:00
|
|
|
final List<StreamInfoItem> streams,
|
2017-11-04 18:30:01 +00:00
|
|
|
final int index) {
|
2020-04-15 13:31:53 +00:00
|
|
|
super(serviceId, url, nextPage, streams, index);
|
2017-08-29 15:00:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-11-03 03:34:12 +00:00
|
|
|
protected String getTag() {
|
|
|
|
return "PlaylistPlayQueue@" + Integer.toHexString(hashCode());
|
2017-08-29 15:00:11 +00:00
|
|
|
}
|
|
|
|
|
2017-08-31 17:07:18 +00:00
|
|
|
@Override
|
|
|
|
public void fetch() {
|
2017-11-03 03:34:12 +00:00
|
|
|
if (this.isInitial) {
|
2017-11-02 06:38:18 +00:00
|
|
|
ExtractorHelper.getPlaylistInfo(this.serviceId, this.baseUrl, false)
|
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
2017-11-03 03:34:12 +00:00
|
|
|
.subscribe(getHeadListObserver());
|
2017-11-02 06:38:18 +00:00
|
|
|
} else {
|
2020-04-15 13:31:53 +00:00
|
|
|
ExtractorHelper.getMorePlaylistItems(this.serviceId, this.baseUrl, this.nextPage)
|
2017-11-02 06:38:18 +00:00
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
2018-02-24 21:57:25 +00:00
|
|
|
.subscribe(getNextPageObserver());
|
2017-08-29 00:38:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|