Skip to content

Commit 90c36cb

Browse files
HatakeKakashriTobiGr
authored andcommitted
Add enqueue option to router dialog
- This allows users to enqueue a stream directly to the current player queue when sharing a link with the app, improving the user experience for queue management. - The 'Enqueue' option is now available in the action selection dialog and can also be set as the preferred open action in the settings.
1 parent 01dee9d commit 90c36cb

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/RouterActivity.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ protected void onSuccess() {
316316
if (choiceChecker.isAvailableAndSelected(
317317
R.string.video_player_key,
318318
R.string.background_player_key,
319-
R.string.popup_player_key)) {
319+
R.string.popup_player_key,
320+
R.string.enqueue_key)) {
320321

321322
final String selectedChoice = choiceChecker.getSelectedChoiceKey();
322323

@@ -329,6 +330,8 @@ protected void onSuccess() {
329330
|| selectedChoice.equals(getString(R.string.popup_player_key));
330331
final boolean isAudioPlayerSelected =
331332
selectedChoice.equals(getString(R.string.background_player_key));
333+
final boolean isEnqueueSelected =
334+
selectedChoice.equals(getString(R.string.enqueue_key));
332335

333336
if (currentLinkType != LinkType.STREAM
334337
&& ((isExtAudioEnabled && isAudioPlayerSelected)
@@ -345,7 +348,9 @@ protected void onSuccess() {
345348

346349
// Check if the service supports the choice
347350
if ((isVideoPlayerSelected && capabilities.contains(VIDEO))
348-
|| (isAudioPlayerSelected && capabilities.contains(AUDIO))) {
351+
|| (isAudioPlayerSelected && capabilities.contains(AUDIO))
352+
|| (isEnqueueSelected && (capabilities.contains(VIDEO)
353+
|| capabilities.contains(AUDIO)))) {
349354
handleChoice(selectedChoice);
350355
} else {
351356
handleChoice(getString(R.string.show_info_key));
@@ -544,7 +549,10 @@ private List<AdapterChoiceItem> getChoicesForService(final StreamingService serv
544549
// not be added to a playlist
545550
returnedItems.add(new AdapterChoiceItem(getString(R.string.add_to_playlist_key),
546551
getString(R.string.add_to_playlist),
547-
R.drawable.ic_add));
552+
R.drawable.ic_playlist_add));
553+
554+
returnedItems.add(new AdapterChoiceItem(getString(R.string.enqueue_key),
555+
getString(R.string.enqueue_stream), R.drawable.ic_add));
548556
} else {
549557
// LinkType.NONE is never present because it's filtered out before
550558
// channels and playlist can be played as they contain a list of videos
@@ -1016,6 +1024,8 @@ public Consumer<Info> getResultHandler(final Choice choice) {
10161024
NavigationHelper.playOnBackgroundPlayer(this, playQueue, true);
10171025
} else if (choice.playerChoice.equals(popupPlayerKey)) {
10181026
NavigationHelper.playOnPopupPlayer(this, playQueue, true);
1027+
} else if (choice.playerChoice.equals(getString(R.string.enqueue_key))) {
1028+
NavigationHelper.enqueueOnPlayer(this, playQueue);
10191029
}
10201030
};
10211031
}

app/src/main/res/values/settings_keys.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@
479479
<string name="popup_player_key">popup_player</string>
480480
<string name="download_key">download</string>
481481
<string name="add_to_playlist_key">add_to_playlist</string>
482+
<string name="enqueue_key">enqueue</string>
482483
<string name="always_ask_open_action_key">always_ask_player</string>
483484

484485
<string-array name="preferred_open_action_description_list">
@@ -488,6 +489,7 @@
488489
<item>@string/popup_player</item>
489490
<item>@string/download</item>
490491
<item>@string/add_to_playlist</item>
492+
<item>@string/enqueue_stream</item>
491493
<item>@string/always_ask_open_action</item>
492494
</string-array>
493495
<string-array name="preferred_open_action_values_list">
@@ -498,6 +500,7 @@
498500
<item>@string/download_key</item>
499501
<item>@string/add_to_playlist_key</item>
500502
<item>@string/always_ask_open_action_key</item>
503+
<item>@string/enqueue_key</item>
501504
</string-array>
502505

503506
<!-- Updates -->

0 commit comments

Comments
 (0)