AVAudioPlayer doesn't work in visionOS

I've been trying to make a native version of my iPad app which uses AVAudioPlayer. Everything works fine in iOS and iPad OS, however, when running on visionOS, it sounds like it's constantly skipping (both in the simulator and on an actual device).

Anyone know why this might be or how to fix or a workaround?

Post not yet marked as solved Up vote post of kudit Down vote post of kudit
355 views

Replies

Running into the same issue. For me, it works fine in preview and in simulator, but I'm getting oscillating track volume. Attaching code for reference

    let exerciseTrackPath = Bundle.main.path(forResource: "vivaldi_winter", ofType: "mp3")
    var audioPlayer: AVAudioPlayer = AVAudioPlayer()

...
        self.audioPlayer = try! AVAudioPlayer(contentsOf: URL(fileURLWithPath: exerciseTrackPath!))
...
        audioPlayer.play()