2
我想在Apple TV上打開我的應用時播放一段視頻(20秒)。但我無法找到如何從本地文件實現URL。使用tvOS從本地文件播放視頻
這是我這麼遠,但遺憾的是它不工作:
override func viewDidLoad() {
super.viewDidLoad()
// I know this is how to play a file from a webserver:
// player = AVPlayer(URL: NSURL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!)
// But I can't find how to set the URL to a local file in the app
let path = NSBundle.mainBundle().pathForResource("bunny", ofType:"mp4")
let url = NSURL.fileURLWithPath(path!)
player = AVPlayer(URL: url)
player?.play()
}