Fixes #116. Listen to audio focus change
This commit is contained in:
parent
bf7f836465
commit
8e377d0e74
1 changed files with 7 additions and 2 deletions
|
@ -167,7 +167,7 @@ class MediaPlayer extends React.PureComponent {
|
|||
|
||||
togglePlay = () => {
|
||||
this.showPlayerControls();
|
||||
this.setState({ paused: !this.state.paused }, this.handlePausedState);
|
||||
this.setState({ paused: !this.state.paused }, this.updateBackgroundMediaNotification);
|
||||
};
|
||||
|
||||
handlePausedState = () => {
|
||||
|
@ -188,7 +188,7 @@ class MediaPlayer extends React.PureComponent {
|
|||
};
|
||||
|
||||
onEnd = () => {
|
||||
this.setState({ paused: true });
|
||||
this.setState({ paused: true }, this.updateBackgroundMediaNotification);
|
||||
if (this.props.onPlaybackFinished) {
|
||||
this.props.onPlaybackFinished();
|
||||
}
|
||||
|
@ -327,6 +327,10 @@ class MediaPlayer extends React.PureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
onFocusChanged = evt => {
|
||||
this.setState({ paused: !(this.state.paused && evt.hasAudioFocus) }, this.updateBackgroundMediaNotification);
|
||||
};
|
||||
|
||||
onBuffer = () => {
|
||||
if (!this.state.paused) {
|
||||
this.setState({ buffering: true }, () => this.manualHidePlayerControls());
|
||||
|
@ -469,6 +473,7 @@ class MediaPlayer extends React.PureComponent {
|
|||
onEnd={this.onEnd}
|
||||
onError={this.onError}
|
||||
minLoadRetryCount={999}
|
||||
onAudioFocusChanged={this.onFocusChanged}
|
||||
/>
|
||||
|
||||
{this.state.firstPlay && thumbnail && (
|
||||
|
|
Loading…
Reference in a new issue