You can set the background color at AVPlayerView:
@IBOutlet weak var videoView: AVPlayerView!
override func awakeFromNib() {
videoView.wantsLayer = true
videoView.layer?.backgroundColor = NSColor.red.cgColor
let url = URL(fileURLWithPath: "your file path")
playerItem = AVPlayerItem.init(url: url)
player = AVPlayer.init(playerItem: playerItem)
player?.allowsExternalPlayback = true
videoView.player = player
player?.currentItem?.addObserver(self, forKeyPath: "status", options: NSKeyValueObservingOptions(rawValue: 0), context: nil)
}
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if let currentPlayer = player , let playerObject = object as? AVPlayerItem, playerObject == currentPlayer.currentItem, keyPath == "status"
{
if ( currentPlayer.currentItem!.status == .readyToPlay)
{
currentPlayer.play()
currentPlayer.rate = 1.0;
}
}
}