我已經做了一些非常沉重的挖掘我覺得,一直沒能找到我的錯誤在xcode 7中使用swift 2.0在應用程序中播放視頻的原因...AVPlayerViewController視頻與迅速2.0 xcode 7測試版3
我可能會缺少一堆東西......我是在應用程序中添加視頻的新手,但最近我已經看到關於此主題的一堆不同的代碼。感謝您的幫助或指點!
import UIKit
import AVKit
import AVFoundation
class ProfileTableViewController: UITableViewController {
var moviePlayer : AVPlayerViewController!
@IBAction func playButton(sender: AnyObject) {
let path = NSBundle.mainBundle().pathForResource("SampleVideo_1080x720_1mb.mp4", ofType:"mp4")
let url = NSURL.fileURLWithPath(path!)
self.moviePlayer = AVPlayerViewController()
if let player = self.moviePlayer {
player.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
player.view.sizeToFit()
/* Scale the movie player to fit the aspect ratio */
player.scalingMode = .AspectFit
player.controlStyle = MPMovieControlStyle.None
player.movieSourceType = MPMovieSourceType.File; player.repeatMode = MPMovieRepeatMode.One;
player.play()
self.view.addSubview(player.view)
}
}