VEX-4556: The app crashes when the premium episode is loaded (#4)

Fix player crashing when it is being cleared.
This commit is contained in:
Armands Malejev 2021-05-07 11:37:57 +03:00 committed by GitHub
parent 61e6535b2f
commit f6cce0d819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,6 +86,14 @@ public final class ExoPlayerView extends FrameLayout {
addViewInLayout(layout, 0, aspectRatioParams); addViewInLayout(layout, 0, aspectRatioParams);
} }
private void clearVideoView() {
if (surfaceView instanceof TextureView) {
player.clearVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
player.clearVideoSurfaceView((SurfaceView) surfaceView);
}
}
private void setVideoView() { private void setVideoView() {
if (surfaceView instanceof TextureView) { if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView); player.setVideoTextureView((TextureView) surfaceView);
@ -125,10 +133,10 @@ public final class ExoPlayerView extends FrameLayout {
return; return;
} }
if (this.player != null) { if (this.player != null) {
this.player.addTextOutput(null); this.player.removeTextOutput(componentListener);
this.player.removeVideoListener(componentListener); this.player.removeVideoListener(componentListener);
this.player.removeListener(componentListener); this.player.removeListener(componentListener);
this.player.setVideoSurface(null); clearVideoView();
} }
this.player = player; this.player = player;
shutterView.setVisibility(VISIBLE); shutterView.setVisibility(VISIBLE);