Mister M
Mister M

Reputation: 1669

ExoPlayer switching media source without black screen

I'm using exoplayer in my project, when switching mediasource i just use

player.stop();
player.prepare(mediaSource);

This causes approx. 0.5 seconds black screen until it switches video.

Is there a way to tell exoplayer to retain last frame from previous video (instead of 0.5 sec black screen) until new video is started?

Upvotes: 10

Views: 11900

Answers (3)

Mister M
Mister M

Reputation: 1669

simpleExoPlayerView.setShutterBackgroundColor(Color.TRANSPARENT);

Upvotes: 20

Vandana Singh
Vandana Singh

Reputation: 41

In my case I'm having a single instance on SimpleExoPlayer and i used to set this via setPlayer in exoplayer view with changed video url's but having blank screen when scroll back to previously played videos.

I just used setPlayer(null) before again setting the player in exoplayerview and the black screen issue fixed.

Upvotes: 2

Anubhav Malik
Anubhav Malik

Reputation: 241

Exoplayer's developers have provided solution to this issue here.

Simply add this line using your SimplePlayerView instance

playerView.setKeepContentOnPlayerReset(true);

Alternatively, you can also do this via your layout.xml file,

app:keep_content_on_player_reset="true"

Upvotes: 9

Related Questions