mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-11-18 07:44:56 +00:00
-Reverted current item removal and update logic.
-Updated external play queue.
This commit is contained in:
parent
f9eb2a1ee5
commit
86c7b8522e
@ -267,6 +267,7 @@ public abstract class BasePlayer implements Player.EventListener,
|
|||||||
final int serviceId = intent.getIntExtra(ExternalPlayQueue.SERVICE_ID, -1);
|
final int serviceId = intent.getIntExtra(ExternalPlayQueue.SERVICE_ID, -1);
|
||||||
final int index = intent.getIntExtra(ExternalPlayQueue.INDEX, 0);
|
final int index = intent.getIntExtra(ExternalPlayQueue.INDEX, 0);
|
||||||
final Serializable serializable = intent.getSerializableExtra(ExternalPlayQueue.STREAMS);
|
final Serializable serializable = intent.getSerializableExtra(ExternalPlayQueue.STREAMS);
|
||||||
|
final String url = intent.getStringExtra(ExternalPlayQueue.URL);
|
||||||
final String nextPageUrl = intent.getStringExtra(ExternalPlayQueue.NEXT_PAGE_URL);
|
final String nextPageUrl = intent.getStringExtra(ExternalPlayQueue.NEXT_PAGE_URL);
|
||||||
|
|
||||||
List<InfoItem> info = new ArrayList<>();
|
List<InfoItem> info = new ArrayList<>();
|
||||||
@ -276,7 +277,7 @@ public abstract class BasePlayer implements Player.EventListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayQueue queue = new ExternalPlayQueue(serviceId, nextPageUrl, info, index);
|
final PlayQueue queue = new ExternalPlayQueue(serviceId, url, nextPageUrl, info, index);
|
||||||
initPlayback(this, queue);
|
initPlayback(this, queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,14 +120,11 @@ public class PlaybackManager {
|
|||||||
break;
|
break;
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
final RemoveEvent removeEvent = (RemoveEvent) event;
|
final RemoveEvent removeEvent = (RemoveEvent) event;
|
||||||
if (removeEvent.isCurrent()) tryBlock();
|
if (!removeEvent.isCurrent()) {
|
||||||
remove(removeEvent.index(), true);
|
remove(removeEvent.index());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case UPDATE:
|
case UPDATE:
|
||||||
final UpdateEvent updateEvent = (UpdateEvent) event;
|
|
||||||
tryBlock();
|
|
||||||
remove(updateEvent.index(), false);
|
|
||||||
break;
|
|
||||||
case SHUFFLE:
|
case SHUFFLE:
|
||||||
tryBlock();
|
tryBlock();
|
||||||
resetSources();
|
resetSources();
|
||||||
@ -275,7 +272,7 @@ public class PlaybackManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void remove(final int queueIndex, final boolean cascade) {
|
private void remove(final int queueIndex) {
|
||||||
if (queueIndex < 0) return;
|
if (queueIndex < 0) return;
|
||||||
|
|
||||||
final int sourceIndex = sourceToQueueIndex.indexOf(queueIndex);
|
final int sourceIndex = sourceToQueueIndex.indexOf(queueIndex);
|
||||||
@ -284,11 +281,9 @@ public class PlaybackManager {
|
|||||||
sourceToQueueIndex.remove(sourceIndex);
|
sourceToQueueIndex.remove(sourceIndex);
|
||||||
sources.removeMediaSource(sourceIndex);
|
sources.removeMediaSource(sourceIndex);
|
||||||
|
|
||||||
if (cascade) {
|
// Will be slow on really large arrays, fast enough for typical use case
|
||||||
// Will be slow on really large arrays, fast enough for typical use case
|
for (int i = sourceIndex; i < sourceToQueueIndex.size(); i++) {
|
||||||
for (int i = sourceIndex; i < sourceToQueueIndex.size(); i++) {
|
sourceToQueueIndex.set(i, sourceToQueueIndex.get(i) - 1);
|
||||||
sourceToQueueIndex.set(i, sourceToQueueIndex.get(i) - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ public final class ExternalPlayQueue extends PlayQueue {
|
|||||||
public static final String SERVICE_ID = "service_id";
|
public static final String SERVICE_ID = "service_id";
|
||||||
public static final String INDEX = "index";
|
public static final String INDEX = "index";
|
||||||
public static final String STREAMS = "streams";
|
public static final String STREAMS = "streams";
|
||||||
|
public static final String URL = "url";
|
||||||
public static final String NEXT_PAGE_URL = "next_page_url";
|
public static final String NEXT_PAGE_URL = "next_page_url";
|
||||||
|
|
||||||
private static final int RETRY_COUNT = 2;
|
private static final int RETRY_COUNT = 2;
|
||||||
@ -30,17 +31,20 @@ public final class ExternalPlayQueue extends PlayQueue {
|
|||||||
private boolean isComplete;
|
private boolean isComplete;
|
||||||
|
|
||||||
private int serviceId;
|
private int serviceId;
|
||||||
private String playlistUrl;
|
private String baseUrl;
|
||||||
|
private String nextUrl;
|
||||||
|
|
||||||
private transient Disposable fetchReactor;
|
private transient Disposable fetchReactor;
|
||||||
|
|
||||||
public ExternalPlayQueue(final int serviceId,
|
public ExternalPlayQueue(final int serviceId,
|
||||||
|
final String url,
|
||||||
final String nextPageUrl,
|
final String nextPageUrl,
|
||||||
final List<InfoItem> streams,
|
final List<InfoItem> streams,
|
||||||
final int index) {
|
final int index) {
|
||||||
super(index, extractPlaylistItems(streams));
|
super(index, extractPlaylistItems(streams));
|
||||||
|
|
||||||
this.playlistUrl = nextPageUrl;
|
this.baseUrl = url;
|
||||||
|
this.nextUrl = nextPageUrl;
|
||||||
this.serviceId = serviceId;
|
this.serviceId = serviceId;
|
||||||
|
|
||||||
this.isComplete = nextPageUrl == null || nextPageUrl.isEmpty();
|
this.isComplete = nextPageUrl == null || nextPageUrl.isEmpty();
|
||||||
@ -53,7 +57,7 @@ public final class ExternalPlayQueue extends PlayQueue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetch() {
|
public void fetch() {
|
||||||
ExtractorHelper.getMorePlaylistItems(this.serviceId, this.playlistUrl)
|
ExtractorHelper.getMorePlaylistItems(this.serviceId, this.baseUrl, this.nextUrl)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.retry(RETRY_COUNT)
|
.retry(RETRY_COUNT)
|
||||||
@ -74,7 +78,7 @@ public final class ExternalPlayQueue extends PlayQueue {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(@NonNull ListExtractor.NextItemsResult result) {
|
public void onSuccess(@NonNull ListExtractor.NextItemsResult result) {
|
||||||
if (!result.hasMoreStreams()) isComplete = true;
|
if (!result.hasMoreStreams()) isComplete = true;
|
||||||
playlistUrl = result.nextItemsUrl;
|
nextUrl = result.nextItemsUrl;
|
||||||
|
|
||||||
append(extractPlaylistItems(result.nextItemsList));
|
append(extractPlaylistItems(result.nextItemsList));
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ public class NavigationHelper {
|
|||||||
.putExtra(ExternalPlayQueue.SERVICE_ID, info.service_id)
|
.putExtra(ExternalPlayQueue.SERVICE_ID, info.service_id)
|
||||||
.putExtra(ExternalPlayQueue.INDEX, index)
|
.putExtra(ExternalPlayQueue.INDEX, index)
|
||||||
.putExtra(ExternalPlayQueue.STREAMS, streams)
|
.putExtra(ExternalPlayQueue.STREAMS, streams)
|
||||||
|
.putExtra(ExternalPlayQueue.URL, info.url)
|
||||||
.putExtra(ExternalPlayQueue.NEXT_PAGE_URL, info.next_streams_url);
|
.putExtra(ExternalPlayQueue.NEXT_PAGE_URL, info.next_streams_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user