Pages

02 July, 2024

How do iI fix the error with UIViewControllerRepresentable?

I got the error on my visionOS app saying that my view doesn't conform to UIViewControllerRepresentable. I tried this code in another visionOS project and it works. Is there anything I can dp?
import SwiftUI
import AVKit
import UIKit

struct PlayerView: UIViewControllerRepresentable {
typealias UIViewControllerType = AVPlayerViewController

var url: String = "
https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_adv_example_hevc/master.m3u8" />
func makeUIViewController(context: Context) -> AVPlayerViewController {
let controller = AVPlayerViewController()
// controller.navigationItem.hidesBackButton = true
// controller.showsPlaybackControls = false

controller.player = AVPlayer(url: URL(string: url)!)
controller.player?.playImmediately(atRate: 1.0)

return controller
}

func updateUIViewController(_ uiViewController: AVPlayerViewController, context: Context) {

}

class Coordinator: NSObject, AVPlayerViewControllerDelegate {
}

func makeCoordinator() -> Coordinator {
Coordinator()
}
}



a prompt answer.....

No comments:

Post a Comment

Thanks