我对使用swiftUI还是相当陌生,并且正在尝试通过自己的vimeo和youtube帐户在应用程序中播放视频,但是即使经过数小时的上网搜索,我也无法弄清楚。有没有解决的办法。我可以正常播放其他来源的mp4视频
struct player: UIViewControllerRepresentable {
func makeUIViewController(context: UIViewControllerRepresentableContext<player>) -> AVPlayerViewController {
let controller = AVPlayerViewController()
let url = "https://vimeo.com/413494928"
let player1 = AVPlayer(url: URL(string: url)!)
controller.player = player1
return controller
}
func updateUIViewController(_ uiViewController: AVPlayerViewController, context: UIViewControllerRepresentableContext<player>) {
}
}
只需播放
func makeUIViewController(context: UIViewControllerRepresentableContext<player>) -> AVPlayerViewController {
let controller = AVPlayerViewController()
let url = "https://vimeo.com/413494928"
let player1 = AVPlayer(url: URL(string: url)!)
controller.player = player1
player1.play() // << here !!
return controller
}