From 91ccf32f77d76a9a3100c17e7d86918a90d9cbe1 Mon Sep 17 00:00:00 2001 From: MichaelR416 Date: Tue, 30 Jan 2024 19:27:11 -0500 Subject: [PATCH] Fix media details tag for multiple versions support (cherry picked from commit 9ec9de0ba16a75747d34a3954f79e19ecff4c42b) --- .../androidtv/util/InfoLayoutHelper.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/jellyfin/androidtv/util/InfoLayoutHelper.java b/app/src/main/java/org/jellyfin/androidtv/util/InfoLayoutHelper.java index 8e77f2bacf..d2236a8134 100644 --- a/app/src/main/java/org/jellyfin/androidtv/util/InfoLayoutHelper.java +++ b/app/src/main/java/org/jellyfin/androidtv/util/InfoLayoutHelper.java @@ -107,7 +107,7 @@ public static void addInfoRow(Context context, BaseItemDto item, int mediaSource if (includeRuntime) addRuntime(context, item, layout, includeEndTime); addSeriesStatus(context, item, layout); addRatingAndRes(context, item, mediaSourceIndex, layout); - addMediaDetails(context, audioStream, layout); + addMediaDetails(context, item, mediaSourceIndex, layout); } private static void addText(Context context, String text, LinearLayout layout, int maxWidth) { @@ -392,25 +392,27 @@ private static void addVideoCodecDetails(Context context, LinearLayout layout, M } } - private static void addMediaDetails(Context context, MediaStream stream, LinearLayout layout) { + private static void addMediaDetails(Context context, BaseItemDto item, int mediaSourceIndex, LinearLayout layout) { - if (stream != null) { - if (stream.getProfile() != null && stream.getProfile().contains("Dolby Atmos")) { + MediaStream audioStream = StreamHelper.getFirstAudioStream(item, mediaSourceIndex); + + if (audioStream != null) { + if (audioStream.getProfile() != null && audioStream.getProfile().contains("Dolby Atmos")) { addBlockText(context, layout, "ATMOS"); addSpacer(context, layout, " "); - } else if (stream.getProfile() != null && stream.getProfile().contains("DTS:X")) { + } else if (audioStream.getProfile() != null && audioStream.getProfile().contains("DTS:X")) { addBlockText(context, layout, "DTS:X"); addSpacer(context, layout, " "); } else { String codec = null; - if (stream.getProfile() != null && stream.getProfile().contains("DTS-HD")) { + if (audioStream.getProfile() != null && audioStream.getProfile().contains("DTS-HD")) { codec = "DTS-HD"; - } else if (stream.getCodec() != null && stream.getCodec().trim().length() > 0) { - switch (stream.getCodec().toLowerCase()) { + } else if (audioStream.getCodec() != null &audioStream.getCodec().trim().length() > 0) { + switch (audioStream.getCodec().toLowerCase()) { case "dca": codec = "DTS"; break; case "eac3": codec = "DD+"; break; case "ac3": codec = "DD"; break; - default: codec = stream.getCodec().toUpperCase(); + default: codec = audioStream.getCodec().toUpperCase(); } } if (codec != null) { @@ -418,8 +420,8 @@ private static void addMediaDetails(Context context, MediaStream stream, LinearL addSpacer(context, layout, " "); } } - if (stream.getChannelLayout() != null && stream.getChannelLayout().trim().length() > 0) { - addBlockText(context, layout, stream.getChannelLayout().toUpperCase()); + if (audioStream.getChannelLayout() != null && audioStream.getChannelLayout().trim().length() > 0) { + addBlockText(context, layout, audioStream.getChannelLayout().toUpperCase()); addSpacer(context, layout, " "); } }