Hello :)
First things first: that piece of code is working on a fast internet connection, and I don't get any error message. As far as I can tell, the problem is that the loading process is placed to the Main Thread. That causes some blocking on slow internet connections. Some others had the same issue (more to find here).
You can try to use this:
struct ContentView: View {
@State private var player = AVPlayer()
var videoUrl: String = "https://video.twimg.com/amplify_video/1760315643142750208/vid/avc1/640x360/-1etorSK7w2g9Nlc.mp4?tag=16"
var body: some View {
VideoPlayer(player: player)
.task {
player = AVPlayer(url: URL(string: videoUrl)!)
}
}
}
Please let me now, if this fixes your error message. If not, we will find a solution.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: