Here is a code snippet about AVPlayer.
avPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 60), queue: .main) { [weak self] _ in
// Call main actor-isolated instance methods
}
Xcode shows warnings that Call to main actor-isolated instance method '***' in a synchronous nonisolated context; this is an error in the Swift 6 language mode. How can I fix this?
avPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 60), queue: .main) { [weak self] _ in
Task { @MainActor in
// Call main actor-isolated instance methods
}
}
Can I use this solution above? But it seems switching actors frequently can slow down performance.
Post
Replies
Boosts
Views
Activity
I like the roundedBorder style, but I want to make it more round like a capsule. How to do this?
If I got a file or a file URL, how to judge it is a spatial photo, a panorama photo or a spatial video? Apple's Photo app can do it.
I want to create a ModelEntity that can glow like lightsaber in Star wars. Here is the video
https://x.com/devtom7/status/1819743159213031453/
I found that the app AirDraw can export users' draw scenes to a USDZ file. So how can I implement this function using RealityKit?