From 90c36cb2e8c1345da1bfe9aff2eabb4aea7c05f2 Mon Sep 17 00:00:00 2001 From: Hatake Kakashri Date: Wed, 19 Nov 2025 22:36:54 +0530 Subject: [PATCH 1/2] 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. --- .../java/org/schabi/newpipe/RouterActivity.java | 16 +++++++++++++--- app/src/main/res/values/settings_keys.xml | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 3933ade92..515641453 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -316,7 +316,8 @@ public class RouterActivity extends AppCompatActivity { if (choiceChecker.isAvailableAndSelected( R.string.video_player_key, R.string.background_player_key, - R.string.popup_player_key)) { + R.string.popup_player_key, + R.string.enqueue_key)) { final String selectedChoice = choiceChecker.getSelectedChoiceKey(); @@ -329,6 +330,8 @@ public class RouterActivity extends AppCompatActivity { || selectedChoice.equals(getString(R.string.popup_player_key)); final boolean isAudioPlayerSelected = selectedChoice.equals(getString(R.string.background_player_key)); + final boolean isEnqueueSelected = + selectedChoice.equals(getString(R.string.enqueue_key)); if (currentLinkType != LinkType.STREAM && ((isExtAudioEnabled && isAudioPlayerSelected) @@ -345,7 +348,9 @@ public class RouterActivity extends AppCompatActivity { // Check if the service supports the choice if ((isVideoPlayerSelected && capabilities.contains(VIDEO)) - || (isAudioPlayerSelected && capabilities.contains(AUDIO))) { + || (isAudioPlayerSelected && capabilities.contains(AUDIO)) + || (isEnqueueSelected && (capabilities.contains(VIDEO) + || capabilities.contains(AUDIO)))) { handleChoice(selectedChoice); } else { handleChoice(getString(R.string.show_info_key)); @@ -544,7 +549,10 @@ public class RouterActivity extends AppCompatActivity { // not be added to a playlist returnedItems.add(new AdapterChoiceItem(getString(R.string.add_to_playlist_key), getString(R.string.add_to_playlist), - R.drawable.ic_add)); + R.drawable.ic_playlist_add)); + + returnedItems.add(new AdapterChoiceItem(getString(R.string.enqueue_key), + getString(R.string.enqueue_stream), R.drawable.ic_add)); } else { // LinkType.NONE is never present because it's filtered out before // channels and playlist can be played as they contain a list of videos @@ -1016,6 +1024,8 @@ public class RouterActivity extends AppCompatActivity { NavigationHelper.playOnBackgroundPlayer(this, playQueue, true); } else if (choice.playerChoice.equals(popupPlayerKey)) { NavigationHelper.playOnPopupPlayer(this, playQueue, true); + } else if (choice.playerChoice.equals(getString(R.string.enqueue_key))) { + NavigationHelper.enqueueOnPlayer(this, playQueue); } }; } diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index d95d1270c..f33f5eef7 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -479,6 +479,7 @@ popup_player download add_to_playlist + enqueue always_ask_player @@ -488,6 +489,7 @@ @string/popup_player @string/download @string/add_to_playlist + @string/enqueue_stream @string/always_ask_open_action @@ -498,6 +500,7 @@ @string/download_key @string/add_to_playlist_key @string/always_ask_open_action_key + @string/enqueue_key From c596476c06831fb64e7a799780d088eb5fbebf4f Mon Sep 17 00:00:00 2001 From: TobiGr Date: Sun, 14 Dec 2025 13:07:14 +0100 Subject: [PATCH 2/2] Only show enqueue option if play queue is not empty in RouterActivity Make enqueue option avilable for playlists as well --- .../org/schabi/newpipe/RouterActivity.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 515641453..b1c553896 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -531,7 +531,7 @@ public class RouterActivity extends AppCompatActivity { final List capabilities = service.getServiceInfo().getMediaCapabilities(); - if (linkType == LinkType.STREAM) { + if (linkType == LinkType.STREAM || linkType == LinkType.PLAYLIST) { if (capabilities.contains(VIDEO)) { returnedItems.add(videoPlayer); returnedItems.add(popupPlayer); @@ -539,20 +539,28 @@ public class RouterActivity extends AppCompatActivity { if (capabilities.contains(AUDIO)) { returnedItems.add(backgroundPlayer); } - // download is redundant for linkType CHANNEL AND PLAYLIST (till playlist downloading is - // not supported ) - returnedItems.add(new AdapterChoiceItem(getString(R.string.download_key), - getString(R.string.download), - R.drawable.ic_file_download)); - // Add to playlist is not necessary for CHANNEL and PLAYLIST linkType since those can - // not be added to a playlist - returnedItems.add(new AdapterChoiceItem(getString(R.string.add_to_playlist_key), - getString(R.string.add_to_playlist), - R.drawable.ic_playlist_add)); + // Enqueue is only shown if the current queue is not empty. + // However, if the playqueue or the player is cleared after this item was chosen and + // while the item is extracted, it will automatically fall back to background player. + if (PlayerHolder.INSTANCE.getQueueSize() > 0) { + returnedItems.add(new AdapterChoiceItem(getString(R.string.enqueue_key), + getString(R.string.enqueue_stream), R.drawable.ic_add)); + } - returnedItems.add(new AdapterChoiceItem(getString(R.string.enqueue_key), - getString(R.string.enqueue_stream), R.drawable.ic_add)); + if (linkType == LinkType.STREAM) { + // download is redundant for linkType CHANNEL AND PLAYLIST + // (till playlist downloading is not supported ) + returnedItems.add(new AdapterChoiceItem(getString(R.string.download_key), + getString(R.string.download), + R.drawable.ic_file_download)); + + // Add to playlist is not necessary for CHANNEL and PLAYLIST linkType + // since those can not be added to a playlist + returnedItems.add(new AdapterChoiceItem(getString(R.string.add_to_playlist_key), + getString(R.string.add_to_playlist), + R.drawable.ic_playlist_add)); + } } else { // LinkType.NONE is never present because it's filtered out before // channels and playlist can be played as they contain a list of videos