如何在 macOS 上使用 SwiftUI 隐藏视频播放器上的按钮?

How can I hide the buttons on the Video Player with SwiftUI on macOS?

VideoPlayer(player: AVPlayer(url: URL(fileURLWithPath: Bundle.main.path(forResource: "*****", ofType: "mp4")!)))

如何隐藏 VideoPlayer 上的按钮。我希望视频不断重复。 您可以通过导入 AVKit 库来访问 VideoPlayer 对象。

import AVKit

在 macOS 上隐藏视频控件(换行 AVPlayerView):

struct ContentView: View {
    let player = AVPlayer(url: URL(fileURLWithPath: Bundle.main.path(forResource: "IMG_0226", ofType: "mp4")!))
    var body: some View {
        AVPlayerControllerRepresented(player: player)
            .onAppear {
                player.play()
            }
            .frame(width: 400, height: 400)
    }
}

struct AVPlayerControllerRepresented : NSViewRepresentable {
    var player : AVPlayer
    
    func makeNSView(context: Context) -> AVPlayerView {
        let view = AVPlayerView()
        view.controlsStyle = .none
        view.player = player
        return view
    }
    
    func updateNSView(_ nsView: AVPlayerView, context: Context) {
        
    }
}

循环AVPlayerHow do you loop AVPlayer in Swift?