Skip to content

Commit c596476

Browse files
committed
Only show enqueue option if play queue is not empty in RouterActivity
Make enqueue option avilable for playlists as well
1 parent 90c36cb commit c596476

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

app/src/main/java/org/schabi/newpipe/RouterActivity.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -531,28 +531,36 @@ private List<AdapterChoiceItem> getChoicesForService(final StreamingService serv
531531
final List<StreamingService.ServiceInfo.MediaCapability> capabilities =
532532
service.getServiceInfo().getMediaCapabilities();
533533

534-
if (linkType == LinkType.STREAM) {
534+
if (linkType == LinkType.STREAM || linkType == LinkType.PLAYLIST) {
535535
if (capabilities.contains(VIDEO)) {
536536
returnedItems.add(videoPlayer);
537537
returnedItems.add(popupPlayer);
538538
}
539539
if (capabilities.contains(AUDIO)) {
540540
returnedItems.add(backgroundPlayer);
541541
}
542-
// download is redundant for linkType CHANNEL AND PLAYLIST (till playlist downloading is
543-
// not supported )
544-
returnedItems.add(new AdapterChoiceItem(getString(R.string.download_key),
545-
getString(R.string.download),
546-
R.drawable.ic_file_download));
547-
548-
// Add to playlist is not necessary for CHANNEL and PLAYLIST linkType since those can
549-
// not be added to a playlist
550-
returnedItems.add(new AdapterChoiceItem(getString(R.string.add_to_playlist_key),
551-
getString(R.string.add_to_playlist),
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));
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+
}
556564
} else {
557565
// LinkType.NONE is never present because it's filtered out before
558566
// channels and playlist can be played as they contain a list of videos

0 commit comments

Comments
 (0)