mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 00:20:32 +00:00
Code improvements here and there
This commit is contained in:
parent
e5ffa2aa09
commit
8dad6d7e1c
@ -786,10 +786,8 @@ public class DownloadDialog extends DialogFragment
|
|||||||
|
|
||||||
if (format == MediaFormat.TTML) {
|
if (format == MediaFormat.TTML) {
|
||||||
filenameTmp += MediaFormat.SRT.suffix;
|
filenameTmp += MediaFormat.SRT.suffix;
|
||||||
} else {
|
} else if (format != null) {
|
||||||
if (format != null) {
|
filenameTmp += format.suffix;
|
||||||
filenameTmp += format.suffix;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -35,33 +35,35 @@ public class SecondaryStreamHelper<T extends Stream> {
|
|||||||
public static AudioStream getAudioStreamFor(@NonNull final List<AudioStream> audioStreams,
|
public static AudioStream getAudioStreamFor(@NonNull final List<AudioStream> audioStreams,
|
||||||
@NonNull final VideoStream videoStream) {
|
@NonNull final VideoStream videoStream) {
|
||||||
final MediaFormat mediaFormat = videoStream.getFormat();
|
final MediaFormat mediaFormat = videoStream.getFormat();
|
||||||
if (mediaFormat != null) {
|
if (mediaFormat == null) {
|
||||||
switch (mediaFormat) {
|
return null;
|
||||||
case WEBM:
|
}
|
||||||
case MPEG_4:// ¿is mpeg-4 DASH?
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean m4v = (mediaFormat == MediaFormat.MPEG_4);
|
switch (mediaFormat) {
|
||||||
|
case WEBM:
|
||||||
for (final AudioStream audio : audioStreams) {
|
case MPEG_4:// ¿is mpeg-4 DASH?
|
||||||
if (audio.getFormat() == (m4v ? MediaFormat.M4A : MediaFormat.WEBMA)) {
|
break;
|
||||||
return audio;
|
default:
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m4v) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retry, but this time in reverse order
|
final boolean m4v = (mediaFormat == MediaFormat.MPEG_4);
|
||||||
for (int i = audioStreams.size() - 1; i >= 0; i--) {
|
|
||||||
final AudioStream audio = audioStreams.get(i);
|
for (final AudioStream audio : audioStreams) {
|
||||||
if (audio.getFormat() == MediaFormat.WEBMA_OPUS) {
|
if (audio.getFormat() == (m4v ? MediaFormat.M4A : MediaFormat.WEBMA)) {
|
||||||
return audio;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,10 +155,10 @@ public class StreamItemAdapter<T extends Stream, U extends Stream> extends BaseA
|
|||||||
qualityString += " (" + context.getString(R.string.caption_auto_generated) + ")";
|
qualityString += " (" + context.getString(R.string.caption_auto_generated) + ")";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mediaFormat != null) {
|
if (mediaFormat == null) {
|
||||||
qualityString = mediaFormat.getSuffix();
|
|
||||||
} else {
|
|
||||||
qualityString = context.getString(R.string.unknown_quality);
|
qualityString = context.getString(R.string.unknown_quality);
|
||||||
|
} else {
|
||||||
|
qualityString = mediaFormat.getSuffix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user