在我的 macOS 应用程序中,我有一个带有AVPlayerView
. 从 Xcode 运行时,窗口打开并播放视频。但是,当我导出(存档>复制应用程序)应用程序并打开它时,AVPlayerView 崩溃的窗口。
我怀疑问题是应用程序导出时应用程序无法访问视频文件。
import Cocoa
import AVKit
class IntroVC: NSViewController{
override func viewDidLoad() {
super.viewDidLoad()
avViewConfig()
}
@IBOutlet weak var avView: AVPlayerView!
func avViewConfig(){
if let filePath = Bundle.main.path(forResource: "one", ofType: ".mp4") {
let filePathURL = NSURL.fileURL(withPath: filePath)
let player = AVPlayer(url: filePathURL)
avView.player = player
avView.player?.play()
}
}
}