This commit is contained in:
Samet Şahin 2023-01-18 14:53:34 +03:00
parent 07d0c9ebfc
commit 9d72011009

View File

@ -638,7 +638,9 @@ class ReactExoplayerView extends FrameLayout implements
.build(); .build();
player.addListener(self); player.addListener(self);
exoPlayerView.setPlayer(player); exoPlayerView.setPlayer(player);
adsLoader?.setPlayer(player); if (adsLoader != null) {
adsLoader.setPlayer(player);
}
audioBecomingNoisyReceiver.setListener(self); audioBecomingNoisyReceiver.setListener(self);
bandwidthMeter.addEventListener(new Handler(), self); bandwidthMeter.addEventListener(new Handler(), self);
setPlayWhenReady(!isPaused); setPlayWhenReady(!isPaused);
@ -863,14 +865,18 @@ class ReactExoplayerView extends FrameLayout implements
private void releasePlayer() { private void releasePlayer() {
if (player != null) { if (player != null) {
adsLoader?.setPlayer(null); if (adsLoader != null) {
adsLoader.setPlayer(null);
}
updateResumePosition(); updateResumePosition();
player.release(); player.release();
player.removeListener(this); player.removeListener(this);
trackSelector = null; trackSelector = null;
player = null; player = null;
} }
adsLoader?.release(); if (adsLoader != null) {
adsLoader.release();
}
adsLoader = null; adsLoader = null;
progressHandler.removeMessages(SHOW_PROGRESS); progressHandler.removeMessages(SHOW_PROGRESS);
themedReactContext.removeLifecycleEventListener(this); themedReactContext.removeLifecycleEventListener(this);