From a652a85e4371009d609a15a7de6d3e74253f3ea5 Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Mon, 31 Aug 2026 14:11:26 +0300 Subject: [PATCH] fix(android): reset playback service connection on cleanup --- .../exoplayer/ReactExoplayerView.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 9f5fd18673..ab719141dc 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -981,18 +981,21 @@ public void onNullBinding(ComponentName name) { } private void cleanupPlaybackService() { + ServiceConnection connection = playbackServiceConnection; + playbackServiceConnection = null; + try { if(player != null && playbackServiceBinder != null) { playbackServiceBinder.getService().unregisterPlayer(player); } - playbackServiceBinder = null; - - if(playbackServiceConnection != null) { - themedReactContext.unbindService(playbackServiceConnection); + if(connection != null) { + themedReactContext.unbindService(connection); } } catch(Exception e) { - DebugLog.w(TAG, "Cloud not cleanup playback service"); + DebugLog.w(TAG, "Could not clean up playback service"); + } finally { + playbackServiceBinder = null; } } @@ -1215,10 +1218,7 @@ private List buildSubtitleConfigurations() { private void releasePlayer() { if (player != null) { - if(playbackServiceBinder != null) { - playbackServiceBinder.getService().unregisterPlayer(player); - themedReactContext.unbindService(playbackServiceConnection); - } + cleanupPlaybackService(); updateResumePosition(); player.release();