Push to talk block Audio session

I'm facing an issue where I can't play an audio file stored in my project after receiving a push-to-talk notification. Strangely, I'm able to play the audio file by tapping on a button before receiving the push notification, but it doesn't work afterward without any error messages. I've ensured that I've set up everything correctly in my project's capabilities. Any insights on what might be causing this issue would be greatly appreciated.

I set everything in capabilities

Set permission in .plist

Request permission in app delegate

I make connection to the room when app becomes active and received succes

Then I setup .halfDuplex for this channel

In restoredChannelUUID I activate AVAudioSession

After sending the ppt push, I parse speaker and make it activeRemoteParticipant. I see than delegate function channelManager didActivate works good

Where I tried to play audio from my player

I see this prints in console, but no sound play

Small update

If I use GlobalPlayer.shared.player = try AVAudioPlayer(contentsOf: audioFilename) where audioFilename is link to local file - everything good. But GlobalPlayer.shared.player = AVPlayer(url: url!) where url is link to stream - it doesn't work

How can I fix it for straming link?

The one thing that jumps out at me related to the PushToTalk flow is that you are manually activating the AVAudioSession in the channel restoration callback. When using the PushToTalk framework you should let the system activate/deactivate the AVAudioSession on your behalf so I would remove this manual activation.

I’ve tested a similar code in my own test app using a static recording and the AVPlayer API and was able to play the file successfully in the channelManager(_ channelManager: PTChannelManager, didActivate: AVAudioSession) callback.

Are you trying to play streaming audio via a remote URL (i.e. not on the local file system)? If so you might need to create an AVPlayerItem using the URL first and wait for the status of the item to change to readyToPlay before playing the file. There could also be an issue with the assets that your remote server is sending to the client app. I would setup your AVPlayer code outside of the PushToTalk incoming message flow first and make sure that you can play the audio by manually triggering playback within your app. Once you have that working you can then move your audio code into the PushToTalk callback methods.

Thank you for your answer. I have tired to create a clear app just with this functionality.

And use your recommendation with readyToPlay.

It plays if I use actionv from simple button (before I send push to talk notification). But it doesn't play after push to talk notification

Push to talk block Audio session
 
 
Q