Enqueue: Add auto-select StreamDialogEntry for current PlayerType

This commit is contained in:
vkay94 2020-10-06 13:33:44 +02:00
parent dd55ad61f4
commit cd515993f5
4 changed files with 78 additions and 2 deletions

View file

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