2018-04-15 20:35:00 +02:00
|
|
|
package org.schabi.newpipe.playqueue;
|
2017-08-29 02:38:37 +02:00
|
|
|
|
|
|
|
import org.schabi.newpipe.extractor.InfoItem;
|
2017-11-02 07:38:18 +01:00
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
|
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
2018-03-18 16:37:49 +01:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
2017-09-04 19:23:56 +02:00
|
|
|
import org.schabi.newpipe.util.ExtractorHelper;
|
2017-08-29 02:38:37 +02:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
2017-11-03 04:34:12 +01:00
|
|
|
public final class PlaylistPlayQueue extends AbstractInfoPlayQueue<PlaylistInfo, PlaylistInfoItem> {
|
2017-11-02 07:38:18 +01:00
|
|
|
public PlaylistPlayQueue(final PlaylistInfoItem 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 PlaylistPlayQueue(final PlaylistInfo info) {
|
2018-03-18 16:37:49 +01:00
|
|
|
this(info.getServiceId(), info.getUrl(), info.getNextPageUrl(), info.getRelatedItems(), 0);
|
2018-01-23 01:40:00 +01:00
|
|
|
}
|
|
|
|
|
2017-11-02 07:38:18 +01:00
|
|
|
public PlaylistPlayQueue(final int serviceId,
|
2017-11-04 19:30:01 +01:00
|
|
|
final String url,
|
|
|
|
final String nextPageUrl,
|
2018-03-18 16:37:49 +01:00
|
|
|
final List<StreamInfoItem> streams,
|
2017-11-04 19:30:01 +01:00
|
|
|
final int index) {
|
2017-11-03 04:34:12 +01:00
|
|
|
super(serviceId, url, nextPageUrl, streams, index);
|
2017-08-29 17:00:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-11-03 04:34:12 +01:00
|
|
|
protected String getTag() {
|
|
|
|
return "PlaylistPlayQueue@" + Integer.toHexString(hashCode());
|
2017-08-29 17:00:11 +02:00
|
|
|
}
|
|
|
|
|
2017-08-31 19:07:18 +02: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.getPlaylistInfo(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 {
|
|
|
|
ExtractorHelper.getMorePlaylistItems(this.serviceId, this.baseUrl, this.nextUrl)
|
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
2018-02-24 22:57:25 +01:00
|
|
|
.subscribe(getNextPageObserver());
|
2017-08-29 02:38:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|