无法播放本地视频文件

Can't play local video file

我正在尝试使用 Xcode 7.1 播放本地视频。我想要的只是让视频在观看和播放时加载全屏。

import UIKit
import AVFoundation
import AVKit

class myClass: AVPlayerViewController {
    private func playVideo() {
        if let path = NSBundle.mainBundle().pathForResource(“video”, ofType: "mp4") {
            let url = NSURL(fileURLWithPath: path)
            player = AVPlayer(URL: url)
            player?.play()
        }
        else {
            print("Oops, something wrong when playing video.mp4")
        }
    }

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        playVideo() 
    } 
}

我设法找到了解决方法。

import Foundation
import UIKit
import AVKit

class PlayerViewController: AVPlayerViewController, AVPlayerViewControllerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    func playVideo() {

        if let path = NSBundle.mainBundle().pathForResource("video", ofType: "mp4") {
            let url = NSURL(fileURLWithPath: path)
            player = AVPlayer(URL: url)
            player?.play()
        }
        else {
            print("Oops, something wrong when playing video.mp4")
        }
    }

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        playVideo()
    }
}