Fix bug with playInBackground

This commit is contained in:
Marc-Olivier Duval 2017-10-24 22:42:41 -04:00
parent f7b7f2666a
commit ee5818b6ff

View File

@ -167,9 +167,6 @@ class ReactExoplayerView extends FrameLayout implements
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
if (playInBackground) {
return;
}
stopPlayback(); stopPlayback();
} }
@ -209,12 +206,14 @@ class ReactExoplayerView extends FrameLayout implements
player.setMetadataOutput(this); player.setMetadataOutput(this);
exoPlayerView.setPlayer(player); exoPlayerView.setPlayer(player);
audioBecomingNoisyReceiver.setListener(this); audioBecomingNoisyReceiver.setListener(this);
setPlayWhenReady(!isPaused);
playerNeedsSource = true; playerNeedsSource = true;
PlaybackParameters params = new PlaybackParameters(rate, 1f); PlaybackParameters params = new PlaybackParameters(rate, 1f);
player.setPlaybackParameters(params); player.setPlaybackParameters(params);
} }
setPlayWhenReady(!isPaused);
if (playerNeedsSource && srcUri != null) { if (playerNeedsSource && srcUri != null) {
MediaSource mediaSource = buildMediaSource(srcUri, extension); MediaSource mediaSource = buildMediaSource(srcUri, extension);
mediaSource = repeat ? new LoopingMediaSource(mediaSource) : mediaSource; mediaSource = repeat ? new LoopingMediaSource(mediaSource) : mediaSource;