我对iOS很新,而且经验很少。 请有人可以告诉我如何编写我的应用程序,以便打开视频并按下按钮进行播放?我无法在任何地方找到如何做到这一点。任何帮助将不胜感激。
答案 0 :(得分:1)
内部按钮点击事件
let videoURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let player = AVPlayer(URL: videoURL!)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
self.view.layer.addSublayer(playerLayer)
player.play()
答案 1 :(得分:-2)
我认为此代码可以帮助您打开电影播放器。
NSURL *movieURL = [NSURL URLWithString:@"http://example.com/somefile.mp4"];
movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[self presentMoviePlayerViewControllerAnimated:movieController];
[movieController.moviePlayer play];