From 9d7201100967f7eb8186825e951e2191031945ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samet=20=C5=9Eahin?= Date: Wed, 18 Jan 2023 14:53:34 +0300 Subject: [PATCH] fix --- .../com/brentvatne/exoplayer/ReactExoplayerView.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 684dbca5..0c0fbc17 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -638,7 +638,9 @@ class ReactExoplayerView extends FrameLayout implements .build(); player.addListener(self); exoPlayerView.setPlayer(player); - adsLoader?.setPlayer(player); + if (adsLoader != null) { + adsLoader.setPlayer(player); + } audioBecomingNoisyReceiver.setListener(self); bandwidthMeter.addEventListener(new Handler(), self); setPlayWhenReady(!isPaused); @@ -863,14 +865,18 @@ class ReactExoplayerView extends FrameLayout implements private void releasePlayer() { if (player != null) { - adsLoader?.setPlayer(null); + if (adsLoader != null) { + adsLoader.setPlayer(null); + } updateResumePosition(); player.release(); player.removeListener(this); trackSelector = null; player = null; } - adsLoader?.release(); + if (adsLoader != null) { + adsLoader.release(); + } adsLoader = null; progressHandler.removeMessages(SHOW_PROGRESS); themedReactContext.removeLifecycleEventListener(this);