mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Add EventListener.onPlaybackSuppressionReasonChanged
Adding this callback makes sense for completeness (we have similar callbacks for all other playback state properties), and also to detect audio focus loss while buffering which would currently trigger no callback because isPlaying is still false. Issue:#6203 PiperOrigin-RevId: 271347351
This commit is contained in:
parent
a3667decf9
commit
7e46d34788
3 changed files with 19 additions and 1 deletions
|
|
@ -1,5 +1,11 @@
|
|||
# Release notes #
|
||||
|
||||
### 2.10.6 ###
|
||||
|
||||
* Add `Player.onPlaybackSuppressionReasonChanged` to allow listeners to
|
||||
detect playbacks suppressions (e.g. audio focus loss) directly
|
||||
([#6203](https://github.com/google/ExoPlayer/issues/6203)).
|
||||
|
||||
### 2.10.5 (2019-09-20) ###
|
||||
|
||||
* Add `Player.isPlaying` and `EventListener.onIsPlayingChanged` to check whether
|
||||
|
|
|
|||
|
|
@ -260,17 +260,21 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
internalPlayer.setPlayWhenReady(internalPlayWhenReady);
|
||||
}
|
||||
boolean playWhenReadyChanged = this.playWhenReady != playWhenReady;
|
||||
boolean suppressionReasonChanged = this.playbackSuppressionReason != playbackSuppressionReason;
|
||||
this.playWhenReady = playWhenReady;
|
||||
this.playbackSuppressionReason = playbackSuppressionReason;
|
||||
boolean isPlaying = isPlaying();
|
||||
boolean isPlayingChanged = oldIsPlaying != isPlaying;
|
||||
if (playWhenReadyChanged || isPlayingChanged) {
|
||||
if (playWhenReadyChanged || suppressionReasonChanged || isPlayingChanged) {
|
||||
int playbackState = playbackInfo.playbackState;
|
||||
notifyListeners(
|
||||
listener -> {
|
||||
if (playWhenReadyChanged) {
|
||||
listener.onPlayerStateChanged(playWhenReady, playbackState);
|
||||
}
|
||||
if (suppressionReasonChanged) {
|
||||
listener.onPlaybackSuppressionReasonChanged(playbackSuppressionReason);
|
||||
}
|
||||
if (isPlayingChanged) {
|
||||
listener.onIsPlayingChanged(isPlaying);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -365,6 +365,14 @@ public interface Player {
|
|||
*/
|
||||
default void onPlayerStateChanged(boolean playWhenReady, int playbackState) {}
|
||||
|
||||
/**
|
||||
* Called when the value returned from {@link #getPlaybackSuppressionReason()} changes.
|
||||
*
|
||||
* @param playbackSuppressionReason The current {@link PlaybackSuppressionReason}.
|
||||
*/
|
||||
default void onPlaybackSuppressionReasonChanged(
|
||||
@PlaybackSuppressionReason int playbackSuppressionReason) {}
|
||||
|
||||
/**
|
||||
* Called when the value of {@link #isPlaying()} changes.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue