Skip to navigation

Set up on tvOS

Learn how to integrate the FastPix Player SDK into your Apple TV application.

The FastPix Player SDK supports tvOS, letting you add video playback to Apple TV apps with the same features available for iOS.

Prerequisites

  • Add the SDK to your project using Swift Package Manager, following the same steps as for iOS installation.
  • Ensure your Xcode project supports tvOS as a deployment target.

Usage example

import UIKit
import AVKit
import FastPixPlayerSDK
class TVPlayerViewController: UIViewController {
lazy var playerViewController = AVPlayerViewController()
override func viewDidLoad() {
super.viewDidLoad()
self.prepareAvPlayerController()
let playbackOptions = PlaybackOptions(
streamType: "STREAM_TYPE",
playbackToken: "<YOUR_PLAYBACK_TOKEN>"
)
playerViewController.prepare(
playbackID: "<PLAYBACK_ID>",
playbackOptions: playbackOptions
)
playerViewController.player?.play()
}
func prepareAvPlayerController() {
addChild(playerViewController)
playerView.addSubview(playerViewController.view)
playerViewController.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
playerViewController.view.leadingAnchor.constraint(equalTo: playerView.leadingAnchor),
playerViewController.view.trailingAnchor.constraint(equalTo: playerView.trailingAnchor),
playerViewController.view.topAnchor.constraint(equalTo: playerView.topAnchor),
playerViewController.view.bottomAnchor.constraint(equalTo: playerView.bottomAnchor)
])
playerViewController.didMove(toParent: self)
}
}

Replace STREAM_TYPE with "on-demand" or "live", and provide your actual playback ID and token.