MEMixerChannel.cpp:1577 此平台不支持空间化 (err=-4)

Bjo*_*aye 6 avaudioplayer swift watchos

我在仅限手表的应用程序中播放声音,但每次播放声音时调试器都会显示错误:“MEMixerChannel.cpp:1577 此平台不支持空间化 (err=-4)”

有人知道为什么吗?是因为我正在为 WatchOS 开发吗?

负责播放声音的经理:

import Foundation
import AVFoundation

final class SoundManager {
    
    var player: AVAudioPlayer?
    
    func playSound(name: String, volume: Float = 1.0) {
        if let url = Bundle.main.url(forResource: name, withExtension: "aif") {
            
            do {
                player = try AVAudioPlayer(contentsOf: url)
                player?.prepareToPlay()
                player?.setVolume(volume, fadeDuration: 0.5)
            } catch {
                print("Error getting the audio file: \(error.localizedDescription)")
            }
        }
        
        player?.play()
    }
}
Run Code Online (Sandbox Code Playgroud)

lor*_*sum 2

这是因为你正在为 Apple Watch 开发。

如果您查看开发者网站上的“空间化算法”,您会发现在任何情况下,WatchOS 都不包含在“可用性”中。

https://developer.apple.com/documentation/audiounit/audio_unit_properties/spatialization_algorithms

更详细的播放音频方式允许您删除该选项,但常规AVPlayer似乎没有任何内容。

https://developer.apple.com/documentation/arkit/usdz_schemas_for_ar/actions_and_triggers/audioaction/auralmode