Add a method to distinguish whether a player can be set by MediaSession

PiperOrigin-RevId: 388835913
This commit is contained in:
sungsoo 2021-08-05 03:07:35 +01:00 committed by Christos Tsilopoulos
parent 7375fe3105
commit a533d8190a
3 changed files with 18 additions and 0 deletions

View File

@ -89,6 +89,16 @@ public abstract class BasePlayer implements Player {
return getAvailableCommands().contains(command); return getAvailableCommands().contains(command);
} }
/**
* {@inheritDoc}
*
* <p>BasePlayer and its descendents will return {@code true}.
*/
@Override
public final boolean canAdvertiseSession() {
return true;
}
@Override @Override
public final void play() { public final void play() {
setPlayWhenReady(true); setPlayWhenReady(true);

View File

@ -151,6 +151,11 @@ public class ForwardingPlayer implements Player {
return player.isCommandAvailable(command); return player.isCommandAvailable(command);
} }
@Override
public boolean canAdvertiseSession() {
return player.canAdvertiseSession();
}
@Override @Override
public Commands getAvailableCommands() { public Commands getAvailableCommands() {
return player.getAvailableCommands(); return player.getAvailableCommands();

View File

@ -1543,6 +1543,9 @@ public interface Player {
*/ */
boolean isCommandAvailable(@Command int command); boolean isCommandAvailable(@Command int command);
/** Returns whether the player can be used to advertise a media session. */
boolean canAdvertiseSession();
/** /**
* Returns the player's currently available {@link Commands}. * Returns the player's currently available {@link Commands}.
* *