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

# Complete integration example

> A full example showing how to set up the FastPix iOS Player with video playback and data integration.

A full example showing how to set up the FastPix iOS Player with video playback and data integration.

## Basic player setup

This example creates a `VideoPlayerViewController` that configures an `AVPlayerViewController`, attaches it to the view hierarchy, and starts playback.

```swift
import UIKit
import FastPixPlayerSDK
import AVKit

class VideoPlayerViewController: UIViewController {

    // Playback ID and Token for streaming (set dynamically)
    var playbackID = ""
    var playbackToken = ""

    // Lazy initialization of AVPlayerViewController
    lazy var playerViewController = AVPlayerViewController()

    // MARK: - View Lifecycle

    override func viewDidLoad() {
        super.viewDidLoad()

        // Prepare and attach the AVPlayerViewController to the view
        prepareAvPlayerController()

        // Start playback
        playerViewController.player?.play()
    }

    // MARK: - AVPlayer Setup

    /// Sets up the AVPlayerViewController and attaches it to the view hierarchy
    func prepareAvPlayerController() {
        // Add playerViewController as a child
        playerViewController.willMove(toParent: self)
        addChild(playerViewController)
        view.addSubview(playerViewController.view)
        playerViewController.didMove(toParent: self)

        // Disable autoresizing mask constraints
        playerViewController.view.translatesAutoresizingMaskIntoConstraints = false

        // Constrain player view to safe area
        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)
        ])
    }
}
```

## What's next

* [Monitor video data](/docs/recipes/integrate-with-ios-player) to enable analytics and pass playback metadata.
* [Build a custom player UI](/docs/ios-player/build-a-custom-player-ui) to replace the default controls.
* [Manage playlists](/docs/ios-player/manage-playlists) to play multiple videos in sequence.