From b3d4953da2a5f74d65d99d4bb55948b73b8462d2 Mon Sep 17 00:00:00 2001 From: chrisk325 Date: Fri, 27 Feb 2026 18:59:00 +0530 Subject: [PATCH] add estimated bitrate for known formats --- .../exoplayer/ReactExoplayerView.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/node_modules/react-native-video/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/node_modules/react-native-video/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 41a887b7..95cbeb9e 100644 --- a/node_modules/react-native-video/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/node_modules/react-native-video/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -1605,8 +1605,16 @@ public class ReactExoplayerView extends FrameLayout implements if (format.channelCount != Format.NO_VALUE && format.channelCount > 0) { existing = existing + "|ch:" + format.channelCount; } - if (format.bitrate != Format.NO_VALUE && format.bitrate > 0) { - existing = existing + "|br:" + format.bitrate; + // Use bitrate, fall back to averageBitrate then peakBitrate + int effectiveBitrate = format.bitrate; + if (effectiveBitrate == Format.NO_VALUE || effectiveBitrate <= 0) { + effectiveBitrate = format.averageBitrate; + } + if (effectiveBitrate == Format.NO_VALUE || effectiveBitrate <= 0) { + effectiveBitrate = format.peakBitrate; + } + if (effectiveBitrate != Format.NO_VALUE && effectiveBitrate > 0) { + existing = existing + "|br:" + effectiveBitrate; } if (!existing.isEmpty()) { audioTrack.setTitle(existing); @@ -1810,8 +1818,16 @@ public class ReactExoplayerView extends FrameLayout implements if (format.channelCount != Format.NO_VALUE && format.channelCount > 0) { baseTitle = baseTitle + "|ch:" + format.channelCount; } - if (format.bitrate != Format.NO_VALUE && format.bitrate > 0) { - baseTitle = baseTitle + "|br:" + format.bitrate; + // Use bitrate, fall back to averageBitrate then peakBitrate + int effectiveBitrate = format.bitrate; + if (effectiveBitrate == Format.NO_VALUE || effectiveBitrate <= 0) { + effectiveBitrate = format.averageBitrate; + } + if (effectiveBitrate == Format.NO_VALUE || effectiveBitrate <= 0) { + effectiveBitrate = format.peakBitrate; + } + if (effectiveBitrate != Format.NO_VALUE && effectiveBitrate > 0) { + baseTitle = baseTitle + "|br:" + effectiveBitrate; } track.setTitle(baseTitle); track.setSelected(false); // Don't report selection status - let PlayerView handle it