Skip to content

Commit f6cce0d

Browse files
VEX-4556: The app crashes when the premium episode is loaded (#4)
Fix player crashing when it is being cleared.
1 parent 61e6535 commit f6cce0d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ public ExoPlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
8686
addViewInLayout(layout, 0, aspectRatioParams);
8787
}
8888

89+
private void clearVideoView() {
90+
if (surfaceView instanceof TextureView) {
91+
player.clearVideoTextureView((TextureView) surfaceView);
92+
} else if (surfaceView instanceof SurfaceView) {
93+
player.clearVideoSurfaceView((SurfaceView) surfaceView);
94+
}
95+
}
96+
8997
private void setVideoView() {
9098
if (surfaceView instanceof TextureView) {
9199
player.setVideoTextureView((TextureView) surfaceView);
@@ -125,10 +133,10 @@ public void setPlayer(SimpleExoPlayer player) {
125133
return;
126134
}
127135
if (this.player != null) {
128-
this.player.addTextOutput(null);
136+
this.player.removeTextOutput(componentListener);
129137
this.player.removeVideoListener(componentListener);
130138
this.player.removeListener(componentListener);
131-
this.player.setVideoSurface(null);
139+
clearVideoView();
132140
}
133141
this.player = player;
134142
shutterView.setVisibility(VISIBLE);

0 commit comments

Comments
 (0)