> 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 a FastPix video in your iOS app using a playback ID.

Learn how to play a FastPix video in your iOS app using a playback ID.

The FastPix iOS Player SDK uses `AVPlayerViewController` to stream videos. You provide a playback ID (generated when you upload a video to FastPix), and the SDK handles the rest.

## Prerequisites

* [Install the FastPix iOS Player SDK](/docs/ios-player/install-fastpix-ios-player) in your project.
* A valid playback ID for a video uploaded to FastPix.

## Set up the player

To play a video, create an `AVPlayerViewController`, attach it to your view hierarchy, and call the `prepare` method with your playback ID.

```swift
import UIKit
import FastPixPlayerSDK
import AVKit

class VideoPlayerViewController: UIViewController {

    var playbackID = ""

    lazy var playerViewController = AVPlayerViewController()

    override func viewDidLoad() {
        super.viewDidLoad()

        // Attach the player to the view
        prepareAvPlayerController()

        // Start playback
        playerViewController.prepare(playbackID: playbackID)
        playerViewController.player?.play()
    }

    func prepareAvPlayerController() {
        playerViewController.willMove(toParent: self)
        addChild(playerViewController)
        view.addSubview(playerViewController.view)
        playerViewController.didMove(toParent: self)

        playerViewController.view.translatesAutoresizingMaskIntoConstraints = false

        NSLayoutConstraint.activate([
            playerViewController.view.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
            playerViewController.view.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
            playerViewController.view.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
            playerViewController.view.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
        ])
    }
}
```

## Key parameters

The `prepare` method accepts two parameters:

* **`playbackId`** (required): A unique identifier for the video asset. Make sure you use the correct playback ID to load the intended video.
* **`streamType`** (optional): Specifies whether the content is `"on-demand"` or `"live"`. Defaults to `"on-demand"` if not set.

```swift
// Play an on-demand video (default stream type)
playerViewController.prepare(playbackID: playbackID)
```

## What's next

* [Play live and on-demand streams](/docs/ios-player/play-live-and-on-demand-streams) to configure stream types.
* [Secure video playback](/docs/ios-player/secure-video-playback) to protect private content with tokens.
* [Build a custom player UI](/docs/ios-player/build-a-custom-player-ui) to replace the default controls.