Need to play a mp3 audio using response of websocket in iOS (Swift)

I want to play an audio live streaming with the use of WebSocket and pass it to AVPlayer or any other native iOS player/component.

So after getting mp3 bytes data I want to play those data in a native player of iOS. Can anyone have any code, POC, etc?

Even if we can use any other player. MobileVLCKit I have already tried.

HLS and HTTP are working fine on AVPlayer.

Wanted solution related WebSocket stream.

Replies

You can use AVAssetResourceLoaderDelegate to achieve this. AVAssetResourceLoaderDelegate will allow you to examine the HLS requests from the player and provide the manifests, keys (if applicable), and content. See the following sample code to get started.

https://developer.apple.com/library/archive/samplecode/sc1791/Introduction/Intro.html#//apple_ref/doc/uid/DTS40014357