我有一个通过编码而不是故事板制作的视图控制器来显示视频。视频播放完毕后,我无法让视图控制器返回上一个。我有一个将用户带到视频的按钮,但是当视频完成时,它不会返回到上一个视图控制器。
import AVKit
import AVFoundation
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let player = AVPlayer(url: URL(fileURLWithPath: Bundle.main.path(forResource: "tour", ofType: "mov")!))
let vc = AVPlayerViewController()
vc.player = player
present(vc, animated: true)
}
}
这是我的视频代码。我已经完成了在我的故事板上构建应用程序的所有其他工作