AVPlayerNode + AVAudioEngine

What's the best way of detecting if player node / audio engine is in broken state (for example as a result of AVAudioSession.mediaServicesWereResetNotification). Sometimes it requires being reset, but from time to time it is not enought to just reset it for example

playerNode.reset()
engine.reset()

But also required to reinitialize it

playerNode.reset()
playerNode = .init()
engine.reset()
engine = .init()

Can we subscribe on the broken states and reinitialize them proactively?

Answered by Engineer in 890429022

Please refer to the documentation below for details on handling AVAudioSession.mediaServicesWereResetNotification. https://developer.apple.com/documentation/avfaudio/avaudiosession/mediaserviceswereresetnotification

As stated above, on receiving this notification, apps are expected to recreate (release and create new) and reinitialize the audio objects, including your AVAudioEngine and associated nodes.

Accepted Answer

Please refer to the documentation below for details on handling AVAudioSession.mediaServicesWereResetNotification. https://developer.apple.com/documentation/avfaudio/avaudiosession/mediaserviceswereresetnotification

As stated above, on receiving this notification, apps are expected to recreate (release and create new) and reinitialize the audio objects, including your AVAudioEngine and associated nodes.

AVPlayerNode + AVAudioEngine
 
 
Q