mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-06-26 15:13:00 +00:00
Player/handleIntent: always early return on ENQUEUE an ENQUEUE_NEXT
We can do this, because: 1. if `playQueue` is not null, we return early 2. if `playQueue` is null and we need to enqueue: - the only “proper” case that could be triggered is the `RESUME_PLAYBACK` case, which is never `true` for the queuing intents, see the comment in `NavigationHelper.enqueueOnPlayer` - the generic `else` case is degenerate, because it would crash on `playQueue` being `null`. This makes some sense, because there is no way to trigger the enqueueing logic via the UI currently if there is no video playing yet, in which case `playQueue` is not `null`. So we need to transform this whole if desaster into a big switch.
This commit is contained in:
parent
295acc41e1
commit
e15c10c15e
@ -368,15 +368,20 @@ public final class Player implements PlaybackListener, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve enqueue intents
|
// Resolve enqueue intents
|
||||||
if (intent.getBooleanExtra(ENQUEUE, false) && playQueue != null) {
|
if (intent.getBooleanExtra(ENQUEUE, false)) {
|
||||||
playQueue.append(newQueue.getStreams());
|
if (playQueue != null) {
|
||||||
|
playQueue.append(newQueue.getStreams());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Resolve enqueue next intents
|
// Resolve enqueue next intents
|
||||||
} else if (intent.getBooleanExtra(ENQUEUE_NEXT, false) && playQueue != null) {
|
if (intent.getBooleanExtra(ENQUEUE_NEXT, false)) {
|
||||||
final int currentIndex = playQueue.getIndex();
|
if (playQueue != null) {
|
||||||
playQueue.append(newQueue.getStreams());
|
final int currentIndex = playQueue.getIndex();
|
||||||
playQueue.move(playQueue.size() - 1, currentIndex + 1);
|
playQueue.append(newQueue.getStreams());
|
||||||
|
playQueue.move(playQueue.size() - 1, currentIndex + 1);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user