Clean up playback suppression

PiperOrigin-RevId: 274561876
This commit is contained in:
olly 2019-10-14 13:54:07 +01:00 committed by Oliver Woodman
parent eb677eb4b9
commit c49388aca2
3 changed files with 12 additions and 12 deletions

View File

@ -539,12 +539,15 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({PLAYBACK_SUPPRESSION_REASON_NONE, PLAYBACK_SUPPRESSION_REASON_AUDIO_FOCUS_LOSS}) @IntDef({
PLAYBACK_SUPPRESSION_REASON_NONE,
PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS
})
@interface PlaybackSuppressionReason {} @interface PlaybackSuppressionReason {}
/** Playback is not suppressed. */ /** Playback is not suppressed. */
int PLAYBACK_SUPPRESSION_REASON_NONE = 0; int PLAYBACK_SUPPRESSION_REASON_NONE = 0;
/** Playback is suppressed because audio focus is lost or can't be acquired. */ /** Playback is suppressed due to transient audio focus loss. */
int PLAYBACK_SUPPRESSION_REASON_AUDIO_FOCUS_LOSS = 1; int PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS = 1;
/** /**
* Repeat modes for playback. One of {@link #REPEAT_MODE_OFF}, {@link #REPEAT_MODE_ONE} or {@link * Repeat modes for playback. One of {@link #REPEAT_MODE_OFF}, {@link #REPEAT_MODE_ONE} or {@link
@ -669,13 +672,10 @@ public interface Player {
int getPlaybackState(); int getPlaybackState();
/** /**
* Returns reason why playback is suppressed even if {@link #getPlaybackState()} is {@link * Returns the reason why playback is suppressed even though {@link #getPlayWhenReady()} is {@code
* #STATE_READY} and {@link #getPlayWhenReady()} is {@code true}. * true}, or {@link #PLAYBACK_SUPPRESSION_REASON_NONE} if playback is not suppressed.
* *
* <p>Note that {@link #PLAYBACK_SUPPRESSION_REASON_NONE} indicates that playback is not * @return The current {@link PlaybackSuppressionReason playback suppression reason}.
* suppressed.
*
* @return The current {@link PlaybackSuppressionReason}.
*/ */
@PlaybackSuppressionReason @PlaybackSuppressionReason
int getPlaybackSuppressionReason(); int getPlaybackSuppressionReason();

View File

@ -1452,7 +1452,7 @@ public class SimpleExoPlayer extends BasePlayer
@PlaybackSuppressionReason @PlaybackSuppressionReason
int playbackSuppressionReason = int playbackSuppressionReason =
playWhenReady && playerCommand != AudioFocusManager.PLAYER_COMMAND_PLAY_WHEN_READY playWhenReady && playerCommand != AudioFocusManager.PLAYER_COMMAND_PLAY_WHEN_READY
? Player.PLAYBACK_SUPPRESSION_REASON_AUDIO_FOCUS_LOSS ? Player.PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS
: Player.PLAYBACK_SUPPRESSION_REASON_NONE; : Player.PLAYBACK_SUPPRESSION_REASON_NONE;
player.setPlayWhenReady(playWhenReady, playbackSuppressionReason); player.setPlayWhenReady(playWhenReady, playbackSuppressionReason);
} }

View File

@ -666,8 +666,8 @@ public class EventLogger implements AnalyticsListener {
switch (playbackSuppressionReason) { switch (playbackSuppressionReason) {
case Player.PLAYBACK_SUPPRESSION_REASON_NONE: case Player.PLAYBACK_SUPPRESSION_REASON_NONE:
return "NONE"; return "NONE";
case Player.PLAYBACK_SUPPRESSION_REASON_AUDIO_FOCUS_LOSS: case Player.PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS:
return "AUDIO_FOCUS_LOSS"; return "TRANSIENT_AUDIO_FOCUS_LOSS";
default: default:
return "?"; return "?";
} }