From 37caa7538e5cfc63f5595fc4298a789302961ace Mon Sep 17 00:00:00 2001 From: Andreas Pfurtscheller Date: Sun, 11 Apr 2021 21:42:54 +0200 Subject: [PATCH] Fix macOS build --- Sources/Richi/VideoPlayer+Delegates.swift | 7 ++++++- Sources/Richi/VideoPlayer.swift | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/Richi/VideoPlayer+Delegates.swift b/Sources/Richi/VideoPlayer+Delegates.swift index bb107d1..9995fee 100644 --- a/Sources/Richi/VideoPlayer+Delegates.swift +++ b/Sources/Richi/VideoPlayer+Delegates.swift @@ -5,9 +5,14 @@ // Created by Andreas Pfurtscheller on 10.04.21. // -import UIKit import Foundation +#if canImport(AppKit) +import AppKit +#elseif canImport(UIKit) +import UIKit +#endif + /// A set of methods which allow to respond to video player events. public protocol VideoPlayerDelegate: AnyObject { diff --git a/Sources/Richi/VideoPlayer.swift b/Sources/Richi/VideoPlayer.swift index fdae090..00e8cbb 100644 --- a/Sources/Richi/VideoPlayer.swift +++ b/Sources/Richi/VideoPlayer.swift @@ -211,11 +211,13 @@ public class VideoPlayer: UIView { set { player.replaceCurrentItem(with: newValue) } } + #if canImport(UIKit) public override var contentMode: UIView.ContentMode { didSet { gravity = Richi.Gravity(contentMode: contentMode) } } + #endif // MARK: - Creating a Video Player @@ -596,6 +598,7 @@ extension Richi.Gravity { } } + #if canImport(UIKit) init(contentMode: UIView.ContentMode) { switch contentMode { case .scaleAspectFill: self = .aspectFill @@ -604,6 +607,7 @@ extension Richi.Gravity { default: self = .fill } } + #endif var videoGravity: AVLayerVideoGravity { switch self {