我正在 Xcode 7.2 上用 Swift 构建一个应用程序
我在 ViewController 中添加了一个视频。这是代码:
import UIKit
import AVKit
import AVFoundation
class GymViewController: UIViewController {
var playerViewController = AVPlayerViewController()
var playerView = AVPlayer()
let fileFemaleURL = NSURL(fileURLWithPath:"/Users/marienkoen/Documents/AppDevelopment/ROZsport/ROZsport/GymFemale-2434.m4v")
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func playButtonPressed(sender: AnyObject) {
playerView = AVPlayer(URL: fileFemaleURL)
playerViewController.player = playerView
self.presentViewController(playerViewController, animated: true){
self.playerViewController.player?.play()
}
在模拟器中运行应用程序时,我可以播放此视频,但无法在真实设备上运行。我在这里想念什么?