For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
StatusSupportDiscussionsLog inSign Up
Docs HomeAPI ReferenceVideo on DemandAI FeaturesLive StreamingVideo PlayerVideo DataCloud PlayoutRecipes
Docs HomeAPI ReferenceVideo on DemandAI FeaturesLive StreamingVideo PlayerVideo DataCloud PlayoutRecipes
  • Player SDKs
    • Introduction
  • Web player
    • Install the FastPix web player
    • Play uploaded videos
    • Handle playback errors
  • Android player
    • Install FastPix Android player
    • Set up the player
    • Play uploaded videos
    • Handle playback errors
  • iOS player
    • Install FastPix iOS player
    • Play uploaded videos
    • Handle playback errors
  • Flutter player
    • Install FastPix Flutter player
    • Play uploaded videos
    • Handle playback errors
LogoLogo
StatusSupportDiscussionsLog inSign Up
On this page
  • Prerequisites
  • Set up the player
  • Key parameters
  • What’s next
iOS player

Play uploaded videos

Was this page helpful?
Previous

Handle playback errors

Next
Built with

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

1import UIKit
2import FastPixPlayerSDK
3import AVKit
4
5class VideoPlayerViewController: UIViewController {
6
7 var playbackID = ""
8
9 lazy var playerViewController = AVPlayerViewController()
10
11 override func viewDidLoad() {
12 super.viewDidLoad()
13
14 // Attach the player to the view
15 prepareAvPlayerController()
16
17 // Start playback
18 playerViewController.prepare(playbackID: playbackID)
19 playerViewController.player?.play()
20 }
21
22 func prepareAvPlayerController() {
23 playerViewController.willMove(toParent: self)
24 addChild(playerViewController)
25 view.addSubview(playerViewController.view)
26 playerViewController.didMove(toParent: self)
27
28 playerViewController.view.translatesAutoresizingMaskIntoConstraints = false
29
30 NSLayoutConstraint.activate([
31 playerViewController.view.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
32 playerViewController.view.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
33 playerViewController.view.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
34 playerViewController.view.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
35 ])
36 }
37}

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.
1// Play an on-demand video (default stream type)
2playerViewController.prepare(playbackID: playbackID)

What’s next

  • Play live and on-demand streams to configure stream types.
  • Secure video playback to protect private content with tokens.
  • Build a custom player UI to replace the default controls.