Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for secondary audio track type #11714

Merged
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
6 changes: 4 additions & 2 deletions app/src/main/java/org/schabi/newpipe/util/ListHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ public final class ListHelper {
private static final Set<String> HIGH_RESOLUTION_LIST = Set.of("1440p", "2160p");
// Audio track types in order of priority. 0=lowest, n=highest
private static final List<AudioTrackType> AUDIO_TRACK_TYPE_RANKING =
List.of(AudioTrackType.DESCRIPTIVE, AudioTrackType.DUBBED, AudioTrackType.ORIGINAL);
List.of(AudioTrackType.DESCRIPTIVE, AudioTrackType.SECONDARY, AudioTrackType.DUBBED,
AudioTrackType.ORIGINAL);
// Audio track types in order of priority when descriptive audio is preferred.
private static final List<AudioTrackType> AUDIO_TRACK_TYPE_RANKING_DESCRIPTIVE =
List.of(AudioTrackType.ORIGINAL, AudioTrackType.DUBBED, AudioTrackType.DESCRIPTIVE);
List.of(AudioTrackType.SECONDARY, AudioTrackType.DUBBED, AudioTrackType.ORIGINAL,
AudioTrackType.DESCRIPTIVE);

/**
* List of supported YouTube Itag ids.
Expand Down
23 changes: 9 additions & 14 deletions app/src/main/java/org/schabi/newpipe/util/Localization.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,25 +327,20 @@ public static String audioTrackName(@NonNull final Context context, final AudioS

if (track.getAudioTrackType() != null) {
final String trackType = audioTrackType(context, track.getAudioTrackType());
if (trackType != null) {
return context.getString(R.string.audio_track_name, name, trackType);
}
return context.getString(R.string.audio_track_name, name, trackType);
}
return name;
}

@Nullable
@NonNull
private static String audioTrackType(@NonNull final Context context,
final AudioTrackType trackType) {
switch (trackType) {
case ORIGINAL:
return context.getString(R.string.audio_track_type_original);
case DUBBED:
return context.getString(R.string.audio_track_type_dubbed);
case DESCRIPTIVE:
return context.getString(R.string.audio_track_type_descriptive);
}
return null;
@NonNull final AudioTrackType trackType) {
return switch (trackType) {
case ORIGINAL -> context.getString(R.string.audio_track_type_original);
case DUBBED -> context.getString(R.string.audio_track_type_dubbed);
case DESCRIPTIVE -> context.getString(R.string.audio_track_type_descriptive);
case SECONDARY -> context.getString(R.string.audio_track_type_secondary);
};
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@
<string name="audio_track_type_original">original</string>
<string name="audio_track_type_dubbed">dubbed</string>
<string name="audio_track_type_descriptive">descriptive</string>
<string name="audio_track_type_secondary">secondary</string>
<string name="channel_tab_videos">Videos</string>
<string name="channel_tab_tracks">Tracks</string>
<string name="channel_tab_shorts">Shorts</string>
Expand Down
Loading