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