> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# Control video playback

> Learn how to use play, pause, seek, and other playback controls in the FastPix Android Player.

Learn how to use play, pause, seek, and other playback controls in the FastPix Android Player.

All playback control methods are on `FastPixPlayer` and are safe to call from the main thread. They delegate to Media3 internally.

## Play, pause, and toggle

```kotlin
player.play()             // Start or resume playback
player.pause()            // Pause playback
player.togglePlayPause()  // Toggle between play and pause
```

* **`play()`** starts playback if the player is prepared. If buffering or ready, it resumes. Call `setMediaItem(...)` or `setFastPixMediaItem { ... }` first.
* **`pause()`** pauses playback if currently playing.
* **`togglePlayPause()`** is a convenience method for tap gestures or a single play/pause button.

## Seek to a position

```kotlin
player.seekTo(positionMs = 5_000) // Seek to 5 seconds
```

Seek events are surfaced through `PlaybackListener.onSeekStart` and `onSeekEnd`.

## Query playback state

```kotlin
val pos = player.getCurrentPosition()       // Current position in milliseconds
val duration = player.getDuration()          // Total duration (0L when unknown)
val state = player.getPlaybackState()        // Media3 state: STATE_IDLE/BUFFERING/READY/ENDED
```

Use `getPlaybackState()` with buffering callbacks to show loading spinners in your UI.

## Autoplay

Control whether playback starts automatically when the player is ready:

```kotlin
player.setPlayWhenReady(true)          // Start automatically when ready
val willPlay = player.getPlayWhenReady()
val isAutoPlay = player.autoplay       // Player-level autoplay policy
```

Use `setPlayWhenReady(true)` for a one-off "start when ready" action, or configure `autoplay` through `FastPixPlayer.Builder` for a persistent player-level policy.