How can I turn off the spatial audio effect when AVPlayer is playing in a window?

I use a AVplayer in a window view, I found that when I move the window to different positions, the default behavior is that the sound will change according to the window position. However, in some cases, I don't need this default behavior. I hope the sound doesn't change.

Answered by Vision Pro Engineer in 817284022

Hey @_rdy,

You can use AVAudioSessionSpatialExperience to define the types of spatial audio experiences that your application supports. You can set this using setIntendedSpatialExperience(_:).

Let me know if you have additional questions,
Michael

Accepted Answer

Hey @_rdy,

You can use AVAudioSessionSpatialExperience to define the types of spatial audio experiences that your application supports. You can set this using setIntendedSpatialExperience(_:).

Let me know if you have additional questions,
Michael

The AVAudioSessionSpatialExperience link you provided no longer works. Could you give a code example of what it would look like to disable spatialization on the audio? I have the exact same problem.

Was able to use this code to achieve the desired effect

do { let session = AVAudioSession.sharedInstance() try session.setIntendedSpatialExperience(.bypassed) } catch { }

How can I turn off the spatial audio effect when AVPlayer is playing in a window?
 
 
Q