Skip to content

Preserve Android MediaPlayer paused prop when backgrounding#1082

Merged
cobarx merged 1 commit intomasterfrom
bugfix/mediaplayer-bg-cant-pause
Jun 22, 2018
Merged

Preserve Android MediaPlayer paused prop when backgrounding#1082
cobarx merged 1 commit intomasterfrom
bugfix/mediaplayer-bg-cant-pause

Conversation

@cobarx
Copy link
Contributor

@cobarx cobarx commented Jun 22, 2018

This allows users to set paused when they detect a background event so that when you return to the app, the video is paused.

Example:

state = {
  paused: false
}

componentDidMount() {
  AppState.addEventListener('change', this.onAppStateChange);
}

onAppStateChange = change => {
  if (change === 'background') {
    this.setState({ paused: true });
  }
}

render() {
  return <Video style={...} source={...} paused={this.state.paused} />;
}

This allows users to set paused when they detect a background event so that when you return to the app, the video is paused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant