mirror of
https://github.com/androidx/media.git
synced 2025-05-09 16:40:55 +08:00
Add suppression reason for unsuitable audio route.
A follow up to stopping speaker playback with a Player decorator from https://github.com/androidx/media/issues/15. It looks like we will need to change to using playback suppression to avoid errors like https://github.com/androidx/media/issues/167, when we don't start a foreground service. We may not have this implemented by 1.0, but would like it in the API and it seems to be appropriate. PiperOrigin-RevId: 478835686
This commit is contained in:
parent
36e41059ea
commit
0208b1bfd0
@ -1096,8 +1096,9 @@ public interface Player {
|
||||
* #PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST}, {@link
|
||||
* #PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS}, {@link
|
||||
* #PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY}, {@link
|
||||
* #PLAY_WHEN_READY_CHANGE_REASON_REMOTE} or {@link
|
||||
* #PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM}.
|
||||
* #PLAY_WHEN_READY_CHANGE_REASON_REMOTE}, {@link
|
||||
* #PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM} or {@link
|
||||
* #PLAY_WHEN_READY_CHANGE_REASON_SUPPRESSED_TOO_LONG}.
|
||||
*/
|
||||
// @Target list includes both 'default' targets and TYPE_USE, to ensure backwards compatibility
|
||||
// with Kotlin usages from before TYPE_USE was added.
|
||||
@ -1109,7 +1110,8 @@ public interface Player {
|
||||
PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS,
|
||||
PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY,
|
||||
PLAY_WHEN_READY_CHANGE_REASON_REMOTE,
|
||||
PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM
|
||||
PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM,
|
||||
PLAY_WHEN_READY_CHANGE_REASON_SUPPRESSED_TOO_LONG
|
||||
})
|
||||
@interface PlayWhenReadyChangeReason {}
|
||||
/** Playback has been started or paused by a call to {@link #setPlayWhenReady(boolean)}. */
|
||||
@ -1122,11 +1124,17 @@ public interface Player {
|
||||
int PLAY_WHEN_READY_CHANGE_REASON_REMOTE = 4;
|
||||
/** Playback has been paused at the end of a media item. */
|
||||
int PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM = 5;
|
||||
/**
|
||||
* Playback has been paused because playback has been {@linkplain #getPlaybackSuppressionReason()
|
||||
* suppressed} too long.
|
||||
*/
|
||||
int PLAY_WHEN_READY_CHANGE_REASON_SUPPRESSED_TOO_LONG = 6;
|
||||
|
||||
/**
|
||||
* Reason why playback is suppressed even though {@link #getPlayWhenReady()} is {@code true}. One
|
||||
* of {@link #PLAYBACK_SUPPRESSION_REASON_NONE} or {@link
|
||||
* #PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS}.
|
||||
* of {@link #PLAYBACK_SUPPRESSION_REASON_NONE}, {@link
|
||||
* #PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS} or {@link
|
||||
* #PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_ROUTE}.
|
||||
*/
|
||||
// @Target list includes both 'default' targets and TYPE_USE, to ensure backwards compatibility
|
||||
// with Kotlin usages from before TYPE_USE was added.
|
||||
@ -1135,13 +1143,19 @@ public interface Player {
|
||||
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
|
||||
@IntDef({
|
||||
PLAYBACK_SUPPRESSION_REASON_NONE,
|
||||
PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS
|
||||
PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS,
|
||||
PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_ROUTE
|
||||
})
|
||||
@interface PlaybackSuppressionReason {}
|
||||
/** Playback is not suppressed. */
|
||||
int PLAYBACK_SUPPRESSION_REASON_NONE = 0;
|
||||
/** Playback is suppressed due to transient audio focus loss. */
|
||||
int PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS = 1;
|
||||
/**
|
||||
* Playback is suppressed due to no suitable audio route, such as an attempt to use an internal
|
||||
* speaker instead of bluetooth headphones on Wear OS.
|
||||
*/
|
||||
int PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_ROUTE = 2;
|
||||
|
||||
/**
|
||||
* Repeat modes for playback. One of {@link #REPEAT_MODE_OFF}, {@link #REPEAT_MODE_ONE} or {@link
|
||||
|
Loading…
x
Reference in New Issue
Block a user