> 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.

# Play uploaded videos

> Learn how to play FastPix videos and direct URLs using the FastPix Android Player SDK.

Learn how to play FastPix videos and direct URLs using the FastPix Android Player SDK.

## Play a FastPix video with a playback ID

Use `setFastPixMediaItem` when you have a `playbackId` from the FastPix dashboard. The SDK resolves the playback URL automatically (`https://stream.fastpix.com/{playbackId}.m3u8`).

```kotlin
private fun startPlayback() {
    player?.setFastPixMediaItem {
        playbackId = "YOUR_PLAYBACK_ID" // required
    }
}
```

> **Note:** `streamType` defaults to `on-demand`. Set it to `live-stream` for a live stream.

## Play a direct URL

Use `setMediaItem` when you already have a playback URL (HLS `.m3u8`, DASH, progressive MP4, or other supported format):

```kotlin
player?.setMediaItem(MediaItem.fromUri("https://example.com/video.m3u8"))
```

## Start playback in your Activity

Call the playback setup method from `onStart` to begin streaming:

```kotlin
override fun onStart() {
    super.onStart()
    startPlayback()
}

private fun startPlayback() {
    playbackListener = object : PlaybackListener {
        override fun onPlay() {}
        override fun onPause() {}
        override fun onPlaybackStateChanged(isPlaying: Boolean) {}
        override fun onError(error: PlaybackException) {}
    }
    player?.addPlaybackListener(playbackListener)

    player?.setFastPixMediaItem {
        playbackId = "YOUR_PLAYBACK_ID"
    }
}
```

#### Frequently asked questions

Call `setFastPixMediaItem` and pass the `playbackId` you copied from the FastPix dashboard. The SDK resolves the playback URL automatically (`https://stream.fastpix.com/{playbackId}.m3u8`).

Yes. Use `setMediaItem(MediaItem.fromUri(url))` for a playback URL you already have, including HLS `.m3u8`, DASH, and progressive MP4 or other supported formats.

`setFastPixMediaItem` builds a FastPix stream from a `playbackId` with options like resolution, token, and stream type. `setMediaItem` plays a direct URL you supply, with no FastPix resolution.

`streamType` defaults to `on-demand`. Set it to `live-stream` in the `setFastPixMediaItem` builder to play live content.

## What's next

* [Enable secure video playback](/docs/android-player/enable-secure-video-playback) to protect content with tokens.
* [Set playback resolution](/docs/android-player/set-playback-resolution) to control video quality.
* [Control video playback](/docs/android-player/control-video-playback) for play, pause, and seek.