Thanks a lot for the reply. In specific:
My app is running the matcher as following (snippet from the code session)
if let catalog = try CatalogProvider.catalog(signaturePath: data) {
try matcher.match(catalog: catalog)
}
At this point the app I'm calling a function called playSounds and I'm passing a URL, that is a remote URL of an .mp3 file hosted on my server.
func playSounds(soundUrl: URL, atTime: Double) {
//Remove previous player
self.audioPlayer?.removeObserver(self, forKeyPath: "timeControlStatus")
//Setup new player
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
try AVAudioSession.sharedInstance().setActive(true)
audioPlayer = AVPlayer(url: soundUrl)
audioPlayer?.addObserver(self, forKeyPath: "timeControlStatus", options: [.old,.new], context: &playerContext)
guard let player = audioPlayer
else
{
return
}
player.playImmediately(atRate: 1.0)
player.seek(to: CMTime(seconds: atTime + 2, preferredTimescale: CMTimeScale(1.0)))
} catch let error {
print("ERROR AUDIO",error.localizedDescription)
}
}
After that playSounds function is called, the matcher stop to do any match. It's basically not working and it's returning me the error that I mentioned above.
Platform: iOS 15 on iPhone X.
The match function is below:
func match(catalog: SHCustomCatalog) throws {
session = SHSession(catalog: catalog)
session?.delegate = self
let audioFormat = AVAudioFormat(standardFormatWithSampleRate: audioEngine.inputNode.outputFormat(forBus: 0).sampleRate,
channels: 1)
audioEngine.inputNode.installTap(onBus: 0, bufferSize: 2048, format: audioFormat) { [weak session] buffer, audioTime in
session?.matchStreamingBuffer(buffer, at: audioTime)
}
try AVAudioSession.sharedInstance().setCategory(.record)
AVAudioSession.sharedInstance().requestRecordPermission { [weak self] success in
guard success, let self = self else { return }
try? self.audioEngine.start()
}
}
Post
Replies
Boosts
Views
Activity
Unfortunately it still doesn't work...
It's really weird that the second in which I start to play the sound the matcher is not working anymore or maybe it's the AVAudioSession... I really don't know...
If you have any other idea or suggestions, will be really appreciated.
Thanks a lot !
So! In first instance I setup AVAudioSession.sharedInstance().setCategory(.playAndRecord) only for the matcher! But then I forgot that I have it also when setting up the player. So I did the same inside the Player and it's now working good!
Thanks a lot!
As ActivityKit is not gonna be available on iOS 16 release, you should use Xcode Beta in order to keep working with ActivityKit as its "beta exclusive" for now.