我一直在尝试,但我的代码无效。有人知道为什么吗?感谢。
override func viewDidAppear(animated: Bool) {
var url:NSURL = NSURL(string: "http://techslides.com/demos/sample-videos/small.mp4")!
var moviePlayer = MPMoviePlayerController(contentURL: url)
moviePlayer!.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
moviePlayer!.controlStyle = .None
moviePlayer!.scalingMode = .AspectFill
moviePlayer!.movieSourceType = .Unknown
moviePlayer!.prepareToPlay()
moviePlayer!.shouldAutoplay = true
moviePlayer!.play()
self.view.insertSubview(moviePlayer.view, atIndex:0)
}
答案 0 :(得分:1)
var url:NSURL = NSURL(字符串:“http://techslides.com/demos/sample-videos/small.mp4”)! moviePlayer = MPMoviePlayerController(contentURL:url)
if let player = moviePlayer {
player.view.frame = self.view.bounds
moviePlayer?.controlStyle = MPMovieControlStyle.None
player.prepareToPlay()
player.scalingMode = .AspectFill
player.repeatMode = MPMovieRepeatMode.One
self.view.insertSubview(player.view, atIndex:0)
}