MediaControlConstants

public class MediaControlConstants
extends Object

java.lang.Object
   ↳ android.support.wearable.media.MediaControlConstants


This class is deprecated.
these constants do not affect the bridged media session on Wear 3 devices.

Constants for customising the media controls shown on Wear.

These constants define extras that can be added to a MediaSession, or to custom actions within a session, to customise the appearance and functions of the associated media controls on Wear.

These extras can be added to either a session on the companion device (to affect the media controls that appear on Wear automatically) or a session created on the wearable itself (to affect media controls that appear when the app creates a Notification.MediaStyle notification).

For example, to create a custom action that will appear on Wear:

PlaybackState.CustomAction.Builder actionBuilder =
         new PlaybackState.CustomAction.Builder(action, name, icon);
 Bundle actionExtras = new Bundle();
 actionExtras.putBoolean(MediaControlConstants.EXTRA_CUSTOM_ACTION_SHOW_ON_WEAR, true);
 actionBuilder.setExtras(actionExtras);
 

That custom action will appear after the standard media controls as a notification-style action, unless there is a space on the four-way controls because either skip-next or skip-previous are not supported.

If you do not want the custom action to appear on the four-way controls, you can reserve the left and right spaces on those controls to be for skip-previous and skip-next only by setting extras on the session as in this example:

Bundle sessionExtras = new Bundle();
 sessionExtras.putBoolean(MediaControlConstants.EXTRA_RESERVE_SLOT_SKIP_TO_PREVIOUS, true);
 sessionExtras.putBoolean(MediaControlConstants.EXTRA_RESERVE_SLOT_SKIP_TO_NEXT, true);
 mediaSession.setExtras(sessionExtras);
 

Summary

Constants

String EXTRA_BACKGROUND_COLOR_FROM_THEME

Key for a boolean extra that can be added to a MediaSession to cause the background color of the associated media controls on Wear to be taken from the specified theme.

String EXTRA_CUSTOM_ACTION_SHOW_ON_WEAR

Key for a boolean extra that can be added to a PlaybackState.CustomAction to allow the action to be added to the media controls on Wear.

String EXTRA_RESERVE_SLOT_SKIP_TO_NEXT

Key for a boolean extra that can be added to a MediaSession to ensure that the space used on the four-way controls for the skip-to-next action is not used for a custom action.

String EXTRA_RESERVE_SLOT_SKIP_TO_PREVIOUS

Key for a boolean extra that can be added to a MediaSession to ensure that the space used on the four-way controls for the skip-to-previous action is not used for a custom action.

Public constructors

MediaControlConstants()

Inherited methods

Constants

EXTRA_BACKGROUND_COLOR_FROM_THEME

public static final String EXTRA_BACKGROUND_COLOR_FROM_THEME

Key for a boolean extra that can be added to a MediaSession to cause the background color of the associated media controls on Wear to be taken from the specified theme.

If a specific theme is required for this, one can be specified in the manifest of the app that creates the MediaSession, as a meta-data item with a name of com.google.android.wearable.media.theme. Otherwise the application theme will be used.

For example, the following can be added to the application's manifest to use a specific theme for the media controls:

 <meta-data android:name="com.google.android.wearable.media.theme"
         android:resource="@style/MediaTheme"/>

The color used will be colorPrimaryDark for the given theme.

If this extra is not present, or has a value other than true, the color of the media controls will be derived from the album art.

Constant Value: "android.support.wearable.media.extra.BACKGROUND_COLOR_FROM_THEME"

EXTRA_CUSTOM_ACTION_SHOW_ON_WEAR

public static final String EXTRA_CUSTOM_ACTION_SHOW_ON_WEAR

Key for a boolean extra that can be added to a PlaybackState.CustomAction to allow the action to be added to the media controls on Wear.

Custom actions with this extra will be added to the controls in the order in which they are defined in the PlaybackState. The first such action will take the left space on the four-way control, unless the session supports PlaybackState.ACTION_SKIP_TO_PREVIOUS. The next space available for a custom action is the right space on the four-way control, unless the session supports PlaybackState.ACTION_SKIP_TO_NEXT. Any custom actions that did not find a space on the four-way control will be added after the four-way control as notification-style actions.

To ensure that the left or right space on the four-way control is not taken up by a custom action, even if skip next or skip previous are not supported, use EXTRA_RESERVE_SLOT_SKIP_TO_PREVIOUS or EXTRA_RESERVE_SLOT_SKIP_TO_NEXT.

Constant Value: "android.support.wearable.media.extra.CUSTOM_ACTION_SHOW_ON_WEAR"

EXTRA_RESERVE_SLOT_SKIP_TO_NEXT

public static final String EXTRA_RESERVE_SLOT_SKIP_TO_NEXT

Key for a boolean extra that can be added to a MediaSession to ensure that the space used on the four-way controls for the skip-to-next action is not used for a custom action.

This may be useful if the skip next action is only temporarily unavailable, for example if the current track is the last in a playlist.

Constant Value: "android.support.wearable.media.extra.RESERVE_SLOT_SKIP_TO_NEXT"

EXTRA_RESERVE_SLOT_SKIP_TO_PREVIOUS

public static final String EXTRA_RESERVE_SLOT_SKIP_TO_PREVIOUS

Key for a boolean extra that can be added to a MediaSession to ensure that the space used on the four-way controls for the skip-to-previous action is not used for a custom action.

This may be useful if the skip previous action is only temporarily unavailable, for example if the current track is the first in a playlist.

Constant Value: "android.support.wearable.media.extra.RESERVE_SLOT_SKIP_TO_PREVIOUS"

Public constructors

MediaControlConstants

public MediaControlConstants ()