google/ExoPlayer · error · IllegalStateException

Missing implementation to handle COMMAND_SET_SPEED_AND_PITCH

Error message

Missing implementation to handle COMMAND_SET_SPEED_AND_PITCH

What it means

Default handler behind Player.setPlaybackParameters/setPlaybackSpeed in SimpleBasePlayer: it throws when COMMAND_SET_SPEED_AND_PITCH is advertised but handleSetPlaybackParameters(PlaybackParameters) is not overridden. The base class maps the public speed/pitch API onto this single handler.

Source

Thrown at library/common/src/main/java/com/google/android/exoplayer2/SimpleBasePlayer.java:3008

   *     changes caused by this call.
   */
  @ForOverride
  protected ListenableFuture<?> handleSetShuffleModeEnabled(boolean shuffleModeEnabled) {
    throw new IllegalStateException("Missing implementation to handle COMMAND_SET_SHUFFLE_MODE");
  }

  /**
   * Handles calls to {@link Player#setPlaybackParameters} or {@link Player#setPlaybackSpeed}.
   *
   * <p>Will only be called if {@link Player#COMMAND_SET_SPEED_AND_PITCH} is available.
   *
   * @param playbackParameters The requested {@link PlaybackParameters}.
   * @return A {@link ListenableFuture} indicating the completion of all immediate {@link State}
   *     changes caused by this call.
   */
  @ForOverride
  protected ListenableFuture<?> handleSetPlaybackParameters(PlaybackParameters playbackParameters) {
    throw new IllegalStateException("Missing implementation to handle COMMAND_SET_SPEED_AND_PITCH");
  }

  /**
   * Handles calls to {@link Player#setTrackSelectionParameters}.
   *
   * <p>Will only be called if {@link Player#COMMAND_SET_TRACK_SELECTION_PARAMETERS} is available.
   *
   * @param trackSelectionParameters The requested {@link TrackSelectionParameters}.
   * @return A {@link ListenableFuture} indicating the completion of all immediate {@link State}
   *     changes caused by this call.
   */
  @ForOverride
  protected ListenableFuture<?> handleSetTrackSelectionParameters(
      TrackSelectionParameters trackSelectionParameters) {
    throw new IllegalStateException(
        "Missing implementation to handle COMMAND_SET_TRACK_SELECTION_PARAMETERS");
  }

View on GitHub (pinned to dd430f7053)

Solutions

  1. Override handleSetPlaybackParameters(PlaybackParameters playbackParameters) and reflect the new parameters in State (fallback parameters too, if the backend clamps them).
  2. If speed/pitch control is unsupported, build availableCommands without COMMAND_SET_SPEED_AND_PITCH.
  3. Validate/clamp unreasonable speeds before forwarding to the backend.

Example fix

// before
// no override; UI calls setPlaybackSpeed(2f) -> throws

// after
@Override
protected ListenableFuture<?> handleSetPlaybackParameters(PlaybackParameters params) {
  return updateStateAndNotify(
      state.buildUpon().setPlaybackParameters(params).build());
}
Defensive patterns

Strategy: validation

Validate before calling

if (!supportsSpeedAndPitch) commands.remove(Player.COMMAND_SET_SPEED_AND_PITCH);

Prevention

When it happens

Trigger: player.setPlaybackSpeed(1.5f) or setPlaybackParameters(new PlaybackParameters(1.2f, 0.95f)) on a SimpleBasePlayer subclass whose State includes COMMAND_SET_SPEED_AND_PITCH without a matching override.

Common situations: Custom players that play at fixed rate and never implement speed; speed controls in UI or MediaController (e.g. playback-control layout speed button) hitting the unimplemented command.

Related errors


AI-assisted analysis of google/ExoPlayer@dd430f7053 (2026-08-14). Data as JSON: /api/errors/b9edaadefd17ee78. Report an issue: GitHub.