[ad_1]
I’m making a placeholder app that performs a queue of movies fullscreen on an iPad. I would like each video to play mechanically with none interface. If you faucet, it goes to the following video and immediately begins enjoying that one till you get to the top.
The code I’ve does most of that — it creates a queue of movies that play fullscreen that advance if you faucet the display screen, however the movies don’t play mechanically. The place do I add participant.play() to the code to make it work?
struct ContentView: View {
let participant = AVQueuePlayer(objects: [
AVPlayerItem(asset: AVAsset(url: Bundle.main.url(forResource: "Video 1", withExtension: "mp4")!)),
AVPlayerItem(asset: AVAsset(url: Bundle.main.url(forResource: "Video 2", withExtension: "mp4")!)),
AVPlayerItem(asset: AVAsset(url: Bundle.main.url(forResource: "Video 3", withExtension: "mp4")!)),
AVPlayerItem(asset: AVAsset(url: Bundle.main.url(forResource: "Video 4", withExtension: "mp4")!)),
])
var physique: some View {
AVPlayerControllerRepresented(participant: participant)
.onTapGesture {
participant.advanceToNextItem()
}
}
}
struct AVPlayerControllerRepresented : UIViewControllerRepresentable {
var participant : AVQueuePlayer
func makeUIViewController(context: Context) -> AVPlayerViewController {
let controller = AVPlayerViewController()
controller.participant = participant
controller.showsPlaybackControls = false
return controller
}
func updateUIViewController(_ uiViewController: AVPlayerViewController, context: Context) {
}
}
[ad_2]
