I'm encountering a couple of console messages/error when using AVAudioPlayer from AVFoundation.
The first issue is two messages appearing in the console immediately upon calling the prepareToPlay() method on an AVAudioPlayer instance.
'2022-02-26 15:10:46.372023-0600 TestApp[11705:5688753] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000039488a0> F8BB1C28-BAE8-11D6-9C31-00039315CD46'
'2022-02-26 15:10:46.416502-0600 TestApp[11705:5688753] no saved enable hardware sample rate converter preference found'
This above messages only appear the first time prepareToPlay() is called after an AVAudioPlayer instance is instantiated.
The second issue is the following message appears in the console when the play() method is called on an AVAudioPlayer instance.
'2022-02-26 15:13:53.005976-0600 TestApp[11731:5691158] [aqme] MEMixerChannel.cpp:1639 client <AudioQueueObject@0x7ff03d824600; [0]; play> got error 2003332927 while sending format information'
This message appears every time the play() method is called on an instantiated AVAudioPlayer instance and when the play ends successfully.
Here is a short example:
import Cocoa
import AVFAudio
class ViewController: NSViewController, AVAudioPlayerDelegate {
var player: AVAudioPlayer?
var trackNumber = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
startTimer()
}
@objc func timerMethod() {
playAudioFile(url: URL(fileURLWithPath: "/Users/Shared/Sounds/countdown.mp3"))
}
func startTimer() {
let _ = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timerMethod), userInfo: nil, repeats: false)
}
func playAudioFile(url: URL) {
player = try! AVAudioPlayer(contentsOf: url)
player?.delegate = self
player?.prepareToPlay()
player?.play()
}
@objc func audioPlayerDidFinishPlaying(_ player: AVAudioPlayer, successfully: Bool) {
if trackNumber == 0 {
playAudioFile(url: URL(fileURLWithPath: "/Users/Shared/Sounds/implode.mp3"))
trackNumber += 1
}
}
}
My environment is Xcode 13.2.1/Swift 5.5.2 and macOS 12.2.1 running on a late 2015 Intel iMac.
For reference I read through these answers. The first two are for iOS, and it appears the Apple Forum is for macOS. None of them have a solution that works for me.