【发布时间】:2017-02-27 04:40:45
【问题描述】:
我正在制作一个简单的 iPad 应用程序,以便在按下按钮时播放电影。电影播放,当电影完成后,我想关闭 AVPlayerView 以便它返回主屏幕。 目前,当视频完成时,它会停留在最后一帧。 我现在的 ViewController.Swift。
import UIKit
import AVKit
import AVFoundation
class ViewController: UIViewController {
//MARK : Properties
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
//MARK: Actions
@IBAction func playButton(_ sender: AnyObject) {
let movieURL = Bundle.main.url(forResource: "ElephantSeals", withExtension: "mov")!
let player = AVPlayer(url: movieURL as URL)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true) {
playerViewController.player!.play()
}
// player.actionAtItemEnd = playerViewController.dismiss(animated: true)
}
}
如您所见,我认为 actionAtItemEnd 中可能有一些东西,但我不确定如何实现它。 谢谢。
【问题讨论】:
标签: ios swift avfoundation avkit