Code improvements here and there

This commit is contained in:
Stypox 2022-05-21 12:02:57 +02:00 committed by AudricV
parent e5ffa2aa09
commit 8dad6d7e1c
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
3 changed files with 31 additions and 31 deletions

View File

@ -786,10 +786,8 @@ public class DownloadDialog extends DialogFragment
if (format == MediaFormat.TTML) {
filenameTmp += MediaFormat.SRT.suffix;
} else {
if (format != null) {
filenameTmp += format.suffix;
}
} else if (format != null) {
filenameTmp += format.suffix;
}
break;
default:

View File

@ -35,33 +35,35 @@ public class SecondaryStreamHelper<T extends Stream> {
public static AudioStream getAudioStreamFor(@NonNull final List<AudioStream> audioStreams,
@NonNull final VideoStream videoStream) {
final MediaFormat mediaFormat = videoStream.getFormat();
if (mediaFormat != null) {
switch (mediaFormat) {
case WEBM:
case MPEG_4:// ¿is mpeg-4 DASH?
break;
default:
return null;
}
if (mediaFormat == null) {
return null;
}
final boolean m4v = (mediaFormat == MediaFormat.MPEG_4);
for (final AudioStream audio : audioStreams) {
if (audio.getFormat() == (m4v ? MediaFormat.M4A : MediaFormat.WEBMA)) {
return audio;
}
}
if (m4v) {
switch (mediaFormat) {
case WEBM:
case MPEG_4:// ¿is mpeg-4 DASH?
break;
default:
return null;
}
}
// retry, but this time in reverse order
for (int i = audioStreams.size() - 1; i >= 0; i--) {
final AudioStream audio = audioStreams.get(i);
if (audio.getFormat() == MediaFormat.WEBMA_OPUS) {
return audio;
}
final boolean m4v = (mediaFormat == MediaFormat.MPEG_4);
for (final AudioStream audio : audioStreams) {
if (audio.getFormat() == (m4v ? MediaFormat.M4A : MediaFormat.WEBMA)) {
return audio;
}
}
if (m4v) {
return null;
}
// retry, but this time in reverse order
for (int i = audioStreams.size() - 1; i >= 0; i--) {
final AudioStream audio = audioStreams.get(i);
if (audio.getFormat() == MediaFormat.WEBMA_OPUS) {
return audio;
}
}

View File

@ -155,10 +155,10 @@ public class StreamItemAdapter<T extends Stream, U extends Stream> extends BaseA
qualityString += " (" + context.getString(R.string.caption_auto_generated) + ")";
}
} else {
if (mediaFormat != null) {
qualityString = mediaFormat.getSuffix();
} else {
if (mediaFormat == null) {
qualityString = context.getString(R.string.unknown_quality);
} else {
qualityString = mediaFormat.getSuffix();
}
}