dimitris-c / AudioStreaming

An AudioPlayer/Streaming library for iOS written in Swift using AVAudioEngine.
MIT License
245 stars 51 forks source link

Stream error: unknown error - for remote audio stream (azuracast, aac) #92

Closed shtefane closed 2 weeks ago

shtefane commented 3 weeks ago

Hi, thank you for your work. I have tried to play some remote radio urls (Azuracast, icecast v2.4, aac - format) and getting this error:

"Audio file stream error'd: An unknown error occurred"

I reproduced the issue on your demo app AudioPlayer, added new URL (https://stream-eurodance90.fr:8000/64.aac) and have got the error on play. Screenshot 2024-08-18 at 22 29 11

The error is coming from assignMagicCookieToConverterIfNeeded(). First time the audioConverter is nil, after pressing stop and again play it works with no issues, but sometimes it returns error from the second breakpoint.

dimitris-c commented 3 weeks ago

Can you try removing the fileStreanCallback?.raiseError.audioSystenError(.fileStreanError(.unknownError)))) and let me know if the audio plays?

We might have to treat this failure as non fatal.

shtefane commented 3 weeks ago

Yes, the audio plays if I comment error line, however the metadata is not processed. The problem is audioConverter is not yet created when the assignMagicCookieToConverterIfNeeded() is called. The order functions are called is: assignMagicCookieToConverterIfNeeded() processFormatList(entry: entry, fileStream: fileStream) processDataFormat(entry: entry, fileStream: fileStream) calls -> createAudioConverter() but audioConverter is still nil.

dimitris-c commented 3 weeks ago

What do you mean by "the metadata is not processed."

I'm on holidays so I'll take a look at this next week.

shtefane commented 3 weeks ago

Metadata(now playing) text is not coming, the delegate method is not called. If I stop and play again or switch to a different stream, somehow videoConverter is created and the stream plays with nowPlaying text.

dimitris-c commented 2 weeks ago

Can you give a try on the latest release 1.2.5 and let me know if it fixes this issue? thanks

shtefane commented 2 weeks ago

The playback works without any error from the first time, but the Now Playing appears only when I stop the stream and start it again. The same behaviour is with Enlefko station from demo (you can try it).

dimitris-c commented 2 weeks ago

So That's a different issue - not related with the fatal error you reported

shtefane commented 2 weeks ago

Yes it's different. Thanks for fixing playbacks

dimitris-c commented 2 weeks ago

btw the metadata issue is a bug on the example project, the library parse the metadata correctly

shtefane commented 2 weeks ago

Yes, the bug is in demo example. Metadata is processed well but it comes before the stream start playing and in AudioPlayerControls the isLiveAudioStreaming var is false and Text is just not displayed.

 if let audioMetadata = model.liveAudioMetadata, model.isLiveAudioStreaming {
                Text("Now Playing: \(audioMetadata)")