Skip to content

Commit

Permalink
Never display route selection for iPad apps run on macOS or Catalyst (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos authored Oct 29, 2024
1 parent 478fd41 commit 3ad8981
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Enable video and audio wireless sharing to Apple TV or AirPlay‑enabled receive

## Overview

> Important: AirPlay integration is only meaningful for iOS apps.
> Important: AirPlay integration is only meaningful for iOS apps. Note that iPad apps run on macOS or using Catalyst do not support AirPlay either.
``Player`` natively supports [AirPlay](https://developer.apple.com/airplay/) to compatible receivers. Enabling AirPlay in your app requires some general setup as well as activation on a player basis.

Expand Down
40 changes: 27 additions & 13 deletions Sources/Player/UserInterface/RoutePickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,38 @@
import AVKit
import SwiftUI

private struct _RoutePickerView: UIViewRepresentable {
let prioritizesVideoDevices: Bool
let activeTintColor: Color?

func makeUIView(context: Context) -> AVRoutePickerView {
AVRoutePickerView()
}

func updateUIView(_ uiView: AVRoutePickerView, context: Context) {
uiView.prioritizesVideoDevices = prioritizesVideoDevices
if let activeTintColor {
uiView.activeTintColor = UIColor(activeTintColor)
}
}
}

/// A button to pick a playback route.
///
/// Behavior: h-exp, v-exp
public struct RoutePickerView: UIViewRepresentable {
/// > Important: This button is not available for iPad applications run on macOS or using Catalyst.
public struct RoutePickerView: View {
private var prioritizesVideoDevices: Bool
private var activeTintColor: Color?

public var body: some View {
if !ProcessInfo.processInfo.isRunningOnMac {
_RoutePickerView(prioritizesVideoDevices: prioritizesVideoDevices, activeTintColor: activeTintColor)
}
else {
EmptyView()
}
}

/// Creates a route picker button.
///
/// - Parameter prioritizesVideoDevices: A Boolean setting whether or not the route picker should sort video
Expand All @@ -22,17 +47,6 @@ public struct RoutePickerView: UIViewRepresentable {
public init(prioritizesVideoDevices: Bool = false) {
self.prioritizesVideoDevices = prioritizesVideoDevices
}

public func makeUIView(context: Context) -> AVRoutePickerView {
AVRoutePickerView()
}

public func updateUIView(_ uiView: AVRoutePickerView, context: Context) {
uiView.prioritizesVideoDevices = prioritizesVideoDevices
if let activeTintColor {
uiView.activeTintColor = UIColor(activeTintColor)
}
}
}

public extension RoutePickerView {
Expand Down

0 comments on commit 3ad8981

Please sign in to comment.