{"record":{"id":"e592b59ca157fc43","repo":"google/ExoPlayer","slug":"missing-implementation-to-handle-command-set-shuff","errorCode":null,"errorMessage":"Missing implementation to handle COMMAND_SET_SHUFFLE_MODE","messagePattern":"Missing implementation to handle COMMAND_SET_SHUFFLE_MODE","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/common/src/main/java/com/google/android/exoplayer2/SimpleBasePlayer.java","lineNumber":2994,"sourceCode":"   *     changes caused by this call.\n   */\n  @ForOverride\n  protected ListenableFuture<?> handleSetRepeatMode(@RepeatMode int repeatMode) {\n    throw new IllegalStateException(\"Missing implementation to handle COMMAND_SET_REPEAT_MODE\");\n  }\n\n  /**\n   * Handles calls to {@link Player#setShuffleModeEnabled}.\n   *\n   * <p>Will only be called if {@link Player#COMMAND_SET_SHUFFLE_MODE} is available.\n   *\n   * @param shuffleModeEnabled Whether shuffle mode was requested to be enabled.\n   * @return A {@link ListenableFuture} indicating the completion of all immediate {@link State}\n   *     changes caused by this call.\n   */\n  @ForOverride\n  protected ListenableFuture<?> handleSetShuffleModeEnabled(boolean shuffleModeEnabled) {\n    throw new IllegalStateException(\"Missing implementation to handle COMMAND_SET_SHUFFLE_MODE\");\n  }\n\n  /**\n   * Handles calls to {@link Player#setPlaybackParameters} or {@link Player#setPlaybackSpeed}.\n   *\n   * <p>Will only be called if {@link Player#COMMAND_SET_SPEED_AND_PITCH} is available.\n   *\n   * @param playbackParameters The requested {@link PlaybackParameters}.\n   * @return A {@link ListenableFuture} indicating the completion of all immediate {@link State}\n   *     changes caused by this call.\n   */\n  @ForOverride\n  protected ListenableFuture<?> handleSetPlaybackParameters(PlaybackParameters playbackParameters) {\n    throw new IllegalStateException(\"Missing implementation to handle COMMAND_SET_SPEED_AND_PITCH\");\n  }\n\n  /**\n   * Handles calls to {@link Player#setTrackSelectionParameters}.","sourceCodeStart":2976,"sourceCodeEnd":3012,"githubUrl":"https://github.com/google/ExoPlayer/blob/dd430f7053a1a3958deea3ead6a0565150c06bfc/library/common/src/main/java/com/google/android/exoplayer2/SimpleBasePlayer.java#L2976-L3012","documentation":"Default handler for Player.setShuffleModeEnabled(...) in SimpleBasePlayer: throws IllegalStateException when COMMAND_SET_SHUFFLE_MODE is available but the subclass did not implement handleSetShuffleModeEnabled(boolean).","triggerScenarios":"player.setShuffleModeEnabled(true) — often issued by a MediaController/UI shuffle button — against a SimpleBasePlayer subclass missing the override while its State includes COMMAND_SET_SHUFFLE_MODE.","commonSituations":"Custom players wired into a MediaSession; shuffle toggles from Android Auto/system UI reaching an incompletely implemented player.","solutions":["Override handleSetShuffleModeEnabled(boolean) to store the flag and recalc window indices, returning the future from updateStateAndNotify.","Or drop COMMAND_SET_SHUFFLE_MODE from availableCommands so the toggle is hidden/disabled in connected controllers.","If implementing shuffle, also implement the index-resolution logic (getNextMediaItemIndex) that honors it."],"exampleFix":"// before\n// no override; session controller enables shuffle -> throws\n\n// after\n@Override\nprotected ListenableFuture<?> handleSetShuffleModeEnabled(boolean shuffleModeEnabled) {\n  return updateStateAndNotify(state.buildUpon().setShuffleModeEnabled(shuffleModeEnabled).build());\n}","handlingStrategy":"validation","validationCode":"if (!supportsShuffle) commands.remove(Player.COMMAND_SET_SHUFFLE_MODE);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Implement handleSetShuffleModeEnabled() or exclude COMMAND_SET_SHUFFLE_MODE.","Remember media controllers can trigger shuffle toggles from system UIs.","If implementing shuffle, update index navigation accordingly."],"tags":["simplebaseplayer","custom-player","shuffle","media3","contract"],"backgroundTag":null,"analyzedSha":"dd430f7053a1a3958deea3ead6a0565150c06bfc","analyzedAt":"2026-08-14T12:22:02.982Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}