我在为不同的按钮使用不同的视频时遇到困难。然而,我的第一个按钮有效,但是当我点击第二个按钮时,它会将我带到AppDelegate.swift页面。我附上了我的代码。有什么建议吗?
import UIKit
import AVFoundation
import AVKit
class Chicken_visual_ViewController: UIViewController {
var playerController = AVPlayerViewController()
var playerView = AVPlayer()
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func button1(_ sender: AnyObject) {
var fileURL = NSURL(fileURLWithPath:"/Users/owner/Desktop/video.mp4")
playerView = AVPlayer(url: fileURL as URL)
playerController.player = playerView
self.present(self.playerController, animated: true, completion: {
self.playerController.player?.play()
})
}
@IBAction func button2(_ sender: AnyObject) {
var fileURL2 = NSURL(fileURLWithPath:"/Users/owner/Desktop//video_3.
mp4")
playerView = AVPlayer(url: fileURL2 as URL)
playerController.player = playerView
self.present(self.playerController, animated: true, completion: {
self.playerController.player?.play()
})
}
}