Skip to main content

Network Throttling

Overview

Apps that stream music through the Feed.fm SDK alongside video playback can run into bandwidth contention issues. When both audio and video are competing for the same network connection — for example, a user watching a live stream or a video feed while listening to background music — the video stream can stutter or buffer as the music player aggressively downloads the next audio file.

Both the iOS and Android SDKs provide controls that allow your app to signal the SDK to reduce its network footprint when bandwidth is needed elsewhere. You can use these controls to throttle music downloads in response to your own video playback state, giving video the bandwidth priority it needs while keeping music playback uninterrupted.

iOS

The useBackgroundNetworkServiceType property on FMAudioPlayer tells the operating system to treat the SDK's audio download requests as low-priority background traffic. When enabled, iOS will deprioritize these requests relative to foreground network activity such as video streaming:

// Deprioritize audio downloads when video is playing
[FMAudioPlayer sharedPlayer].useBackgroundNetworkServiceType = YES;

// Restore normal network priority
[FMAudioPlayer sharedPlayer].useBackgroundNetworkServiceType = NO;

The default is NO. This takes effect on the next audio item loaded, so it is best set before or at the start of playback.

- (void)videoPlaybackDidStart {
[FMAudioPlayer sharedPlayer].useBackgroundNetworkServiceType = YES;
}

- (void)videoPlaybackDidStop {
[FMAudioPlayer sharedPlayer].useBackgroundNetworkServiceType = NO;
}

Android

The static enableNetworkThrottle method on FeedAudioPlayer activates a download throttling mode that limits how much data the SDK fetches in each read operation. This smooths out the SDK's network usage and prevents it from saturating the connection during a large audio file download:

// Enable throttling when video playback begins
FeedAudioPlayer.enableNetworkThrottle(true)

// Disable throttling when video playback ends
FeedAudioPlayer.enableNetworkThrottle(false)

Because this is a static setting, it applies globally to the SDK and takes effect immediately. It is safe to toggle at any point during playback.

fun onVideoPlaybackStarted() {
FeedAudioPlayer.enableNetworkThrottle(true)
}

fun onVideoPlaybackStopped() {
FeedAudioPlayer.enableNetworkThrottle(false)
}