Skip to content

Commit

Permalink
VEX-4556: The app crashes when the premium episode is loaded (#4)
Browse files Browse the repository at this point in the history
Fix player crashing when it is being cleared.
  • Loading branch information
armands-malejevs authored May 7, 2021
1 parent 61e6535 commit f6cce0d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ public ExoPlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
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() {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
Expand Down Expand Up @@ -125,10 +133,10 @@ public void setPlayer(SimpleExoPlayer player) {
return;
}
if (this.player != null) {
this.player.addTextOutput(null);
this.player.removeTextOutput(componentListener);
this.player.removeVideoListener(componentListener);
this.player.removeListener(componentListener);
this.player.setVideoSurface(null);
clearVideoView();
}
this.player = player;
shutterView.setVisibility(VISIBLE);
Expand Down

0 comments on commit f6cce0d

Please sign in to comment.