diff --git a/libraries/common/src/main/java/androidx/media3/common/Player.java b/libraries/common/src/main/java/androidx/media3/common/Player.java index 0b3ee05817..822cb506ef 100644 --- a/libraries/common/src/main/java/androidx/media3/common/Player.java +++ b/libraries/common/src/main/java/androidx/media3/common/Player.java @@ -47,26 +47,125 @@ import java.util.ArrayList; import java.util.List; /** - * A media player interface defining traditional high-level functionality, such as the ability to - * play, pause, seek and query properties of the currently playing media. + * A media player interface defining high-level functionality, such as the ability to play, pause, + * seek and query properties of the currently playing media. * - *

All methods must be called from a single {@linkplain #getApplicationLooper() application - * thread} unless indicated otherwise. Callbacks in registered listeners are called on the same - * thread. - * - *

This interface includes some convenience methods that can be implemented by calling other - * methods in the interface. {@link BasePlayer} implements these convenience methods so inheriting - * {@link BasePlayer} is recommended when implementing the interface so that only the minimal set of - * required methods can be implemented. + *

Player features and usage

* *

Some important properties of media players that implement this interface are: * *

+ * + *

API stability guarantees

+ * + *

The majority of the Player interface and its related classes are part of the stable API that + * guarantees backwards-compatibility for users of the API. Only more advances use cases may need to + * rely on {@link UnstableApi} classes and methods that are subject to incompatible changes or even + * removal in a future release. Implementors of the Player interface are not covered by these API + * stability guarantees. + * + *

Player state

+ * + *

Users can listen to state changes by adding a {@link Player.Listener} with {@link + * #addListener}. + * + *

The main elements of the overall player state are: + * + *

+ * + *

Note that there are no callbacks for normal playback progression, only for {@linkplain + * Listener#onMediaItemTransition transitions between media items} and other {@linkplain + * Listener#onPositionDiscontinuity position discontinuities}. Code that needs to monitor playback + * progress (for example, an UI progress bar) should query the current position in appropriate + * intervals. + * + *

Implementing the Player interface

+ * + *

Implementing the Player interface is complex, as the interface includes many convenience + * methods that need to provide a consistent state and behavior, requires correct handling of + * listeners and available commands, and expects immediate state changes even if methods are + * internally handled asynchronously. For this reason, implementations are advised to inherit {@link + * SimpleBasePlayer} that handles all of these complexities and provides a simpler integration point + * for implementors of the interface. */ public interface Player {