Skip to content

Commit

Permalink
Fix macOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
aplr committed Apr 11, 2021
1 parent 282726e commit 37caa75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/Richi/VideoPlayer+Delegates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Richi/VideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -596,6 +598,7 @@ extension Richi.Gravity {
}
}

#if canImport(UIKit)
init(contentMode: UIView.ContentMode) {
switch contentMode {
case .scaleAspectFill: self = .aspectFill
Expand All @@ -604,6 +607,7 @@ extension Richi.Gravity {
default: self = .fill
}
}
#endif

var videoGravity: AVLayerVideoGravity {
switch self {
Expand Down

0 comments on commit 37caa75

Please sign in to comment.