|
69 | 69 | * <li>{@link MediaController#COMMAND_SEEK_TO_NEXT} to seek to the next item.
|
70 | 70 | * </ul>
|
71 | 71 | *
|
| 72 | + * <h2>Custom commands</h2> |
| 73 | + * |
| 74 | + * Custom actions are sent to the session under the hood. You can receive them by overriding the |
| 75 | + * session callback method {@link MediaSession.Callback#onCustomCommand(MediaSession, ControllerInfo |
| 76 | + * controller, SessionCommand, Bundle)}. This is useful because starting with Android 13, the System |
| 77 | + * UI notification sends commands directly to the session. So handling the custom commands on the |
| 78 | + * session level allows you to handle them at the same callback for all API levels. |
| 79 | + * |
72 | 80 | * <h2>Drawables</h2>
|
73 | 81 | *
|
74 | 82 | * The drawables used can be overridden by drawables with the same names defined the application.
|
@@ -219,6 +227,14 @@ public final boolean handleCustomCommand(MediaSession session, String action, Bu
|
219 | 227 | * customized by defining the index of the command in compact view of up to 3 commands in their
|
220 | 228 | * extras with key {@link DefaultMediaNotificationProvider#COMMAND_KEY_COMPACT_VIEW_INDEX}.
|
221 | 229 | *
|
| 230 | + * <p>To make the custom layout and commands work, you need to {@linkplain |
| 231 | + * MediaSession#setCustomLayout(List) set the custom layout of commands} and add the custom |
| 232 | + * commands to the available commands when a controller {@linkplain |
| 233 | + * MediaSession.Callback#onConnect(MediaSession, ControllerInfo) connects to the session}. |
| 234 | + * Controllers that connect after you called {@link MediaSession#setCustomLayout(List)} need the |
| 235 | + * custom command set in {@link MediaSession.Callback#onPostConnect(MediaSession, ControllerInfo)} |
| 236 | + * also. |
| 237 | + * |
222 | 238 | * @param playerCommands The available player commands.
|
223 | 239 | * @param customLayout The {@linkplain MediaSession#setCustomLayout(List) custom layout of
|
224 | 240 | * commands}.
|
|
0 commit comments