@@ -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 ));
@@ -526,25 +531,36 @@ private List<AdapterChoiceItem> getChoicesForService(final StreamingService serv
526531 final List <StreamingService .ServiceInfo .MediaCapability > capabilities =
527532 service .getServiceInfo ().getMediaCapabilities ();
528533
529- if (linkType == LinkType .STREAM ) {
534+ if (linkType == LinkType .STREAM || linkType == LinkType . PLAYLIST ) {
530535 if (capabilities .contains (VIDEO )) {
531536 returnedItems .add (videoPlayer );
532537 returnedItems .add (popupPlayer );
533538 }
534539 if (capabilities .contains (AUDIO )) {
535540 returnedItems .add (backgroundPlayer );
536541 }
537- // download is redundant for linkType CHANNEL AND PLAYLIST (till playlist downloading is
538- // not supported )
539- returnedItems .add (new AdapterChoiceItem (getString (R .string .download_key ),
540- getString (R .string .download ),
541- R .drawable .ic_file_download ));
542-
543- // Add to playlist is not necessary for CHANNEL and PLAYLIST linkType since those can
544- // not be added to a playlist
545- returnedItems .add (new AdapterChoiceItem (getString (R .string .add_to_playlist_key ),
546- getString (R .string .add_to_playlist ),
547- R .drawable .ic_add ));
542+
543+ // Enqueue is only shown if the current queue is not empty.
544+ // However, if the playqueue or the player is cleared after this item was chosen and
545+ // while the item is extracted, it will automatically fall back to background player.
546+ if (PlayerHolder .INSTANCE .getQueueSize () > 0 ) {
547+ returnedItems .add (new AdapterChoiceItem (getString (R .string .enqueue_key ),
548+ getString (R .string .enqueue_stream ), R .drawable .ic_add ));
549+ }
550+
551+ if (linkType == LinkType .STREAM ) {
552+ // download is redundant for linkType CHANNEL AND PLAYLIST
553+ // (till playlist downloading is not supported )
554+ returnedItems .add (new AdapterChoiceItem (getString (R .string .download_key ),
555+ getString (R .string .download ),
556+ R .drawable .ic_file_download ));
557+
558+ // Add to playlist is not necessary for CHANNEL and PLAYLIST linkType
559+ // since those can not be added to a playlist
560+ returnedItems .add (new AdapterChoiceItem (getString (R .string .add_to_playlist_key ),
561+ getString (R .string .add_to_playlist ),
562+ R .drawable .ic_playlist_add ));
563+ }
548564 } else {
549565 // LinkType.NONE is never present because it's filtered out before
550566 // channels and playlist can be played as they contain a list of videos
@@ -1016,6 +1032,8 @@ public Consumer<Info> getResultHandler(final Choice choice) {
10161032 NavigationHelper .playOnBackgroundPlayer (this , playQueue , true );
10171033 } else if (choice .playerChoice .equals (popupPlayerKey )) {
10181034 NavigationHelper .playOnPopupPlayer (this , playQueue , true );
1035+ } else if (choice .playerChoice .equals (getString (R .string .enqueue_key ))) {
1036+ NavigationHelper .enqueueOnPlayer (this , playQueue );
10191037 }
10201038 };
10211039 }
0 commit comments