我在iOS应用程序上播放视频。
func playVideo() {
if let path = NSBundle.mainBundle().pathForResource("video", ofType:"mp4"),
url = NSURL(fileURLWithPath: path),
moviePlayer = MPMoviePlayerController(contentURL: url) {
self.moviePlayer = moviePlayer
moviePlayer.view.frame = self.view.bounds
moviePlayer.prepareToPlay()
moviePlayer.controlStyle = MPMovieControlStyle.None
moviePlayer.view.frame = CGRect(x: 0, y: 0, width: UIScreen.mainScreen().bounds.width, height: UIScreen.mainScreen().bounds.height)
moviePlayer.scalingMode = .AspectFill
self.view.addSubview(moviePlayer.view)
if (oldMoviePlayer != nil){
println("Animation Run")
UIView.transitionFromView(oldMoviePlayer!.view, toView: moviePlayer.view, duration: 1.0, options: transitionOptions, completion: nil)
}
oldMoviePlayer = moviePlayer
} else {
debugPrintln("Ops, something wrong when playing video.m4v")
}
}
现在video.mp4文件保存在我的项目中。
如何从我的设备而不是从项目中播放视频?
我可以从设备获取视频的路径和名称吗?
答案 0 :(得分:-2)
好的,考虑到你的场景,下面的文档可以帮助你 - 它是用目标c编写的,但是你应该能够解决这个问题:
如果您理解了所有内容,请标记为答案:)