我试图在ios应用程序上播放来自本地文件系统的mp4视频.视频大约一个小时,可以快速播放.如果是来自网络,我可以播放mp4(NSURL(字符串:"http:domain.com/vid.mp4")).我正在播放如下视频:
let steamingURL:NSURL = NSURL(string: video.filePath)! //valid path let player = AVPlayer(URL: steamingURL) player.allowsExternalPlayback = false PlayWorkoutViewController.playerController = AVPlayerViewController() PlayWorkoutViewController.playerController.player = player self.addChildViewController(PlayWorkoutViewController.playerController) self.view.addSubview(PlayWorkoutViewController.playerController.view) PlayWorkoutViewController.playerController.view.frame = videoContainerView.frame PlayWorkoutViewController.playerController.showsPlaybackControls = false player.play()
我是否需要更改某些设置才能播放更长的视频?谢谢.
首先检查steamingURL是否为零
如果你想使用NSURL(字符串:"xxx")初始化,请检查字符串以file://开头,否则使用NSURL(fileURLWithPath:"xxxx").