Skip to content

Commit 8814540

Browse files
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 6e0b7be commit 8814540

4 files changed

Lines changed: 19 additions & 6 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/java/org/schabi/newpipe/player/PlayerService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ class PlayerService : MediaBrowserServiceCompat() {
148148
// a (dummy) foreground notification, otherwise we'd incur in
149149
// "Context.startForegroundService() did not then call Service.startForeground()". Then
150150
// we stop the service again.
151-
Log.d(TAG, "onStartCommand() got a useless intent, closing the service");
152-
NotificationUtil.startForegroundWithDummyNotification(this);
151+
Log.d(TAG, "onStartCommand() got a useless intent, closing the service")
152+
NotificationUtil.startForegroundWithDummyNotification(this)
153153
return START_NOT_STICKY
154154
}
155155

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 -->

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ teamnewpipe-nanojson = "e9d656ddb49a412a5a0a5d5ef20ca7ef09549996"
5858
# the corresponding commit hash, since JitPack sometimes deletes artifacts.
5959
# If there’s already a git hash, just add more of it to the end (or remove a letter)
6060
# to cause jitpack to regenerate the artifact.
61-
teamnewpipe-newpipe-extractor = "0023b22095a2d62a60cdfc87f4b5cd85c8b266c3"
61+
teamnewpipe-newpipe-extractor = "0023b22095a2d62a60cdfc87f4b5cd85c8b26"
6262
webkit = "1.9.0"
6363
work = "2.10.0"
6464

0 commit comments

Comments
 (0)