iOS: BASS_StreamCreateURL stops after temporary network connection loss

Started by Alexios,

Alexios

Hi Ian,

I'm developing an Internet radio application for iOS using the latest BASS library.

I'm streaming AAC HTTP radio stations via:

BASS_StreamCreateURL(url, 0, BASS_STREAM_STATUS, NULL, NULL);

Background Audio mode is enabled.

When the network connection is temporarily lost:

- playback stalls immediately;
- after approximately 5 seconds, iOS Control Center changes from Pause to Play, indicating that the system no longer considers the application to be actively playing audio;
- BASS_ChannelIsActive eventually reports BASS_ACTIVE_STOPPED;
- I also see the following log:
AACAudioFile.cpp:259 ReadBytes failed

Once the stream reaches this state, the application is eventually suspended by iOS because it is no longer considered to be playing audio. At that point timers, reachability callbacks and reconnect logic can no longer execute.

I have already tried:

- BASS_CONFIG_IOS_SESSION = BASS_IOS_SESSION_DISABLE
- BASS_CONFIG_NET_TIMEOUT
- BASS_CONFIG_NET_READTIMEOUT
- BASS_STREAM_BLOCK

but the behavior remains the same.

For comparison, AVPlayer behaves differently under the same conditions. During temporary network loss it remains in a waiting state instead of stopping, Control Center continues to display the Pause button, the application stays alive in the background, and playback resumes automatically once network connectivity is restored.

My question is:

Is there any way to keep a BASS_StreamCreateURL stream in a stalled/waiting state during temporary network connection loss instead of allowing it to transition to BASS_ACTIVE_STOPPED?

Or is recreating the stream the only supported approach on iOS?

Any advice would be greatly appreciated.

Thank you!

Ian @ un4seen

By default, BASS suspends its output after 1 second of nothing playing, but you can prevent that via the BASS_CONFIG_DEV_NONSTOP option:

BASS_SetConfig(BASS_CONFIG_DEV_NONSTOP, 1);

You can set that back to 0 when you want BASS to start suspending again. The output status can be checked with BASS_IsStarted.