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
      • Build a custom player UI
      • Add a custom seek bar
      • Add forward and rewind controls
      • Handle orientation changes
  • Flutter player
    • Install FastPix Flutter player
    • Play uploaded videos
    • Handle playback errors
LogoLogo
StatusSupportDiscussionsLog inSign Up
On this page
  • Update layout on rotation
  • Detect the current orientation
iOS playerPlayer UI

Handle orientation changes

Was this page helpful?
Previous

Secure video playback

Next
Built with

Learn how to update your custom player layout when the device orientation changes.

When building a custom player UI, you need to handle orientation transitions to keep your controls properly positioned in both portrait and landscape modes.

Update layout on rotation

Override viewWillTransition(to:with:) to adjust your player constraints during rotation:

1override func viewWillTransition(
2 to size: CGSize,
3 with coordinator: UIViewControllerTransitionCoordinator
4) {
5 super.viewWillTransition(to: size, with: coordinator)
6
7 coordinator.animate(alongsideTransition: { _ in
8 self.updatePlayPauseConstraintsForOrientation()
9 self.view.layoutIfNeeded()
10 })
11}

Detect the current orientation

Use the following helper to check whether the device is in landscape mode:

1private func isLandscapeMode() -> Bool {
2 if #available(iOS 13.0, *) {
3 let orientation = view.window?.windowScene?.interfaceOrientation
4 return orientation == .landscapeLeft || orientation == .landscapeRight
5 } else {
6 return UIApplication.shared.statusBarOrientation.isLandscape
7 }
8}

Use this helper to adjust control positions, padding, or layout constraints based on the current orientation.