diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java
index a5760eddc..f337080a4 100644
--- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java
+++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java
@@ -6,8 +6,12 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.util.Log;
+
+import androidx.annotation.Nullable;
+
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.PlaybackParameters;
+
import org.schabi.newpipe.App;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.extractor.stream.StreamInfo;
@@ -31,6 +35,22 @@ public final class PlayerHolder {
private static MainPlayer playerService;
private static VideoPlayerImpl player;
+ /**
+ * Returns the current {@link MainPlayer.PlayerType} of the {@link MainPlayer} service,
+ * otherwise `null` if no service running.
+ */
+ @Nullable
+ public static MainPlayer.PlayerType getType() {
+ if (player == null) {
+ return null;
+ }
+
+ return player.videoPlayerSelected() ? MainPlayer.PlayerType.VIDEO
+ : player.popupPlayerSelected() ? MainPlayer.PlayerType.POPUP
+ : player.audioPlayerSelected() ? MainPlayer.PlayerType.AUDIO
+ : null;
+ }
+
public static void setListener(final PlayerServiceExtendedEventListener newListener) {
listener = newListener;
// Force reload data from service
diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
index eef70c1e5..3387a86d7 100644
--- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
+++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
@@ -7,17 +7,17 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
-import androidx.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
+import androidx.preference.PreferenceManager;
import com.nostra13.universalimageloader.core.ImageLoader;
@@ -187,6 +187,22 @@ public final class NavigationHelper {
startService(context, intent);
}
+ public static void enqueueOnVideoPlayer(final Context context, final PlayQueue queue,
+ final boolean resumePlayback) {
+ enqueueOnVideoPlayer(context, queue, false, resumePlayback);
+ }
+
+ public static void enqueueOnVideoPlayer(final Context context, final PlayQueue queue,
+ final boolean selectOnAppend,
+ final boolean resumePlayback) {
+
+ final Intent intent = getPlayerEnqueueIntent(
+ context, MainPlayer.class, queue, selectOnAppend, resumePlayback);
+
+ intent.putExtra(VideoPlayer.PLAYER_TYPE, VideoPlayer.PLAYER_TYPE_VIDEO);
+ startService(context, intent);
+ }
+
public static void enqueueOnPopupPlayer(final Context context, final PlayQueue queue,
final boolean resumePlayback) {
enqueueOnPopupPlayer(context, queue, false, resumePlayback);
diff --git a/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java b/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java
index a1e2e6eb9..6c7be293e 100644
--- a/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java
+++ b/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java
@@ -1,12 +1,15 @@
package org.schabi.newpipe.util;
import android.content.Context;
+import android.widget.Toast;
import androidx.fragment.app.Fragment;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
+import org.schabi.newpipe.player.MainPlayer;
+import org.schabi.newpipe.player.helper.PlayerHolder;
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
import java.util.Collections;
@@ -16,6 +19,42 @@ public enum StreamDialogEntry {
// enum values with DEFAULT actions //
//////////////////////////////////////
+ /**
+ * Enqueues the stream automatically to the current PlayerType.
+ *
+ * Info: Add this entry within showStreamDialog.
+ */
+ enqueue_stream(R.string.enqueue_stream, (fragment, item) -> {
+ final MainPlayer.PlayerType type = PlayerHolder.getType();
+
+ if (type == null) {
+ // This code shouldn't be reached since the checks for appending this entry should be
+ // done within the showStreamDialog calls.
+ Toast.makeText(fragment.getContext(),
+ "No player currently playing", Toast.LENGTH_SHORT).show();
+ return;
+ }
+ switch (type) {
+ case AUDIO:
+ NavigationHelper.enqueueOnBackgroundPlayer(fragment.getContext(),
+ new SinglePlayQueue(item), false);
+ break;
+ case POPUP:
+ NavigationHelper.enqueueOnPopupPlayer(fragment.getContext(),
+ new SinglePlayQueue(item), false);
+ break;
+ case VIDEO:
+ NavigationHelper.enqueueOnVideoPlayer(fragment.getContext(),
+ new SinglePlayQueue(item), false);
+ break;
+ default:
+ // Same as above, but keep it for now for debugging.
+ Toast.makeText(fragment.getContext(),
+ "Unreachable code executed", Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }),
+
enqueue_on_background(R.string.enqueue_on_background, (fragment, item) ->
NavigationHelper.enqueueOnBackgroundPlayer(fragment.getContext(),
new SinglePlayQueue(item), false)),
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5b95d110c..aae569fa9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -445,6 +445,7 @@
Details
Audio Settings
Hold to enqueue
+ Enqueue stream
Enqueue in the background
Enqueue in a popup
Start playing here