Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix playInBackground props in ExoPlayer #833

Merged
merged 8 commits into from
Jun 9, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ Toggles a fullscreen player. Access using a ref to the component.

- [Lumpen Radio](https://github.com/jhabdas/lumpen-radio) contains another example integration using local files and full screen background video.

## Use ExoPlayer on Android

To use ExoPlayer instead of the default player, you have to change android to android-exoplayer in settings.gradle

**android/settings.gradle**

```gradle
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
```

## TODOS

- [ ] Add support for captions
Expand Down
3 changes: 1 addition & 2 deletions android-exoplayer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ https://github.com/google/ExoPlayer

## Unimplemented props

- `playInBackground={true}`
- `rate={1.0}`
- Expansion file - `source={{ mainVer: 1, patchVer: 0 }}`

Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ protected void onDetachedFromWindow() {

@Override
public void onHostResume() {
if (playInBackground) {
return;
}
setPlayWhenReady(!isPaused);
}

Expand Down Expand Up @@ -209,12 +206,14 @@ private void initializePlayer() {
player.setMetadataOutput(this);
exoPlayerView.setPlayer(player);
audioBecomingNoisyReceiver.setListener(this);
setPlayWhenReady(!isPaused);
playerNeedsSource = true;

PlaybackParameters params = new PlaybackParameters(rate, 1f);
player.setPlaybackParameters(params);
}

setPlayWhenReady(!isPaused);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this change made, I'm not sure what it does. When testing with my changes, the video plays automatically even if I switch sources.


if (playerNeedsSource && srcUri != null) {
MediaSource mediaSource = buildMediaSource(srcUri, extension);
mediaSource = repeat ? new LoopingMediaSource(mediaSource) : mediaSource;
Expand Down