Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ protected void onSuccess() {
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();

Expand All @@ -329,6 +330,8 @@ protected void onSuccess() {
|| 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)
Expand All @@ -345,7 +348,9 @@ protected void onSuccess() {

// 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));
Expand Down Expand Up @@ -526,25 +531,36 @@ private List<AdapterChoiceItem> getChoicesForService(final StreamingService serv
final List<StreamingService.ServiceInfo.MediaCapability> 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);
}
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_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));
}

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
Expand Down Expand Up @@ -1016,6 +1032,8 @@ public Consumer<Info> getResultHandler(final Choice choice) {
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);
}
};
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@
<string name="popup_player_key">popup_player</string>
<string name="download_key">download</string>
<string name="add_to_playlist_key">add_to_playlist</string>
<string name="enqueue_key">enqueue</string>
<string name="always_ask_open_action_key">always_ask_player</string>

<string-array name="preferred_open_action_description_list">
Expand All @@ -488,6 +489,7 @@
<item>@string/popup_player</item>
<item>@string/download</item>
<item>@string/add_to_playlist</item>
<item>@string/enqueue_stream</item>
<item>@string/always_ask_open_action</item>
</string-array>
<string-array name="preferred_open_action_values_list">
Expand All @@ -498,6 +500,7 @@
<item>@string/download_key</item>
<item>@string/add_to_playlist_key</item>
<item>@string/always_ask_open_action_key</item>
<item>@string/enqueue_key</item>
</string-array>

<!-- Updates -->
Expand Down