From 2e623ca0fb074e64a6125994effb8723f5c4ce59 Mon Sep 17 00:00:00 2001
From: Olivier Bouillet <62574056+freeboub@users.noreply.github.com>
Date: Mon, 13 May 2024 19:19:20 +0200
Subject: [PATCH] fix(avoid): avoid early return in setSrc (#3759)

* perf: ensure we do not provide callback to native if no callback provided from app

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size

* fix(android): avoid easly return in setSrc
---
 .../com/brentvatne/exoplayer/ReactExoplayerView.java  | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
index 9eb60e2275..441f7610a3 100644
--- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
+++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
@@ -1646,14 +1646,13 @@ public void setSrc(final Uri uri, final long startPositionMs, final long cropSta
         if (this.customMetadata != customMetadata && player != null) {
             MediaItem currentMediaItem = player.getCurrentMediaItem();
 
-            if (currentMediaItem == null) {
-                return;
-            }
+            if (currentMediaItem != null) {
 
-            MediaItem newMediaItem = currentMediaItem.buildUpon().setMediaMetadata(customMetadata).build();
+                MediaItem newMediaItem = currentMediaItem.buildUpon().setMediaMetadata(customMetadata).build();
 
-            // This will cause video blink/reload but won't louse progress
-            player.setMediaItem(newMediaItem, false);
+                // This will cause video blink/reload but won't louse progress
+                player.setMediaItem(newMediaItem, false);
+            }
         }
 
         if (uri != null) {