iOS - Play audio from remote URL, with audio meters

So, I've been working on an app, and for part of it I have a record/playback system. For this to work correctly, I need to be able to:
  • Record and play back local audio

  • Use power levels to hook up to an audio level meter

  • Play back remote audio from my server

To be clear, I'm not asking for any help with the UI: I already have a working interface as well as an audio level meter.

The problem is, AVAudioPlayer has audio metering, but it can't stream audio from the network. AVPlayer, on the other hand, can stream audio from the network, but doesn't have audio metering.

I'm not sure what the thought process behind that was, but so far it seems like neither option works. AVAudioPlayer could work if I just downloaded the audio before playing, but it would be a lot nicer if I could just stream it.

Is there something I'm missing, or is it impossible to stream audio with AVAudioPlayer (or have metering with AVPlayer)?
The Accelerate framework has a lot of useful functions for analyzing audio. I recommend you start by looking at this sample project from WWDC 2019:

https://developer.apple.com/documentation/avfoundation/audio_playback_recording_and_processing/avaudioengine/using_voice_processing

It shows one approach to computing RMS power from audio buffers for the purpose of metering.
iOS - Play audio from remote URL, with audio meters
 
 
Q