google/ExoPlayer · error · IllegalStateException

Missing implementation to handle COMMAND_SET_VIDEO_SURFACE

Error message

Missing implementation to handle COMMAND_SET_VIDEO_SURFACE

What it means

Player.setVideoSurface/setVideoSurfaceHolder/setVideoTextureView/etc. all funnel through SimpleBasePlayer.handleSetVideoOutput(Object). The default implementation throws IllegalStateException when COMMAND_SET_VIDEO_SURFACE is present in availableCommands but the subclass never overrode the handler. videoOutput is the opaque Surface/SurfaceHolder/TextureView/SurfaceView instance the caller supplied.

Source

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

  protected ListenableFuture<?> handleSetDeviceMuted(boolean muted, @C.VolumeFlags int flags) {
    throw new IllegalStateException(
        "Missing implementation to handle COMMAND_ADJUST_DEVICE_VOLUME or"
            + " COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS");
  }

  /**
   * Handles calls to set the video output.
   *
   * <p>Will only be called if {@link Player#COMMAND_SET_VIDEO_SURFACE} is available.
   *
   * @param videoOutput The requested video output. This is either a {@link Surface}, {@link
   *     SurfaceHolder}, {@link TextureView} or {@link SurfaceView}.
   * @return A {@link ListenableFuture} indicating the completion of all immediate {@link State}
   *     changes caused by this call.
   */
  @ForOverride
  protected ListenableFuture<?> handleSetVideoOutput(Object videoOutput) {
    throw new IllegalStateException("Missing implementation to handle COMMAND_SET_VIDEO_SURFACE");
  }

  /**
   * Handles calls to clear the video output.
   *
   * <p>Will only be called if {@link Player#COMMAND_SET_VIDEO_SURFACE} is available.
   *
   * @param videoOutput The video output to clear. If null any current output should be cleared. If
   *     non-null, the output should only be cleared if it matches the provided argument. This is
   *     either a {@link Surface}, {@link SurfaceHolder}, {@link TextureView} or {@link
   *     SurfaceView}.
   * @return A {@link ListenableFuture} indicating the completion of all immediate {@link State}
   *     changes caused by this call.
   */
  @ForOverride
  protected ListenableFuture<?> handleClearVideoOutput(@Nullable Object videoOutput) {
    throw new IllegalStateException("Missing implementation to handle COMMAND_SET_VIDEO_SURFACE");
  }

View on GitHub (pinned to dd430f7053)

Solutions

  1. Override handleSetVideoOutput(Object videoOutput), unwrap the Surface (via SurfaceHolder.getSurface() or TextureView-aware helpers) and pass it to your rendering backend; return an immediate future.
  2. Also override handleClearVideoOutput since the same command gates it.
  3. For audio-only players, exclude COMMAND_SET_VIDEO_SURFACE from availableCommands so video calls are ignored.

Example fix

// before
// availableCommands includes COMMAND_SET_VIDEO_SURFACE, no override:

// after
@Override
protected ListenableFuture<?> handleSetVideoOutput(Object videoOutput) {
  if (videoOutput instanceof Surface) {
    renderer.setOutputSurface((Surface) videoOutput);
  } else if (videoOutput instanceof SurfaceHolder) {
    renderer.setOutputSurface(((SurfaceHolder) videoOutput).getSurface());
  }
  return Futures.immediateVoidFuture();
}
Defensive patterns

Strategy: validation

Validate before calling

if (player.isCommandAvailable(Player.COMMAND_SET_VIDEO_SURFACE)) {
  checkOverrides(playerClass, "handleSetVideoOutput");
}

Prevention

When it happens

Trigger: Calling player.setVideoSurface(surface) (or any setVideo* variant) on a custom SimpleBasePlayer that declares COMMAND_SET_VIDEO_SURFACE in State.availableCommands without overriding handleSetVideoOutput.

Common situations: Building an audio-focused custom player but copying a video-capable command set; wrapping a codec or external playback engine and forgetting to attach the surface to it.

Related errors


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