Music Streaming App: Audio Focus, Lock Screen, Offline

Build a Professional Music Streaming App The user switches tracks and hears a click due to unsynchronized audio focus. Or the app goes silent during an incoming call and does not resume. These errors stem from improper configuration of the system audio layer. In this article we break down how to

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1All 1734 services
Music Streaming App: Audio Focus, Lock Screen, Offline
Complex
from 2 weeks to 3 months

Our competencies:

Frequently Asked Questions

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    898
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    784
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1219
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1081
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    1004
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    600

Build a Professional Music Streaming App

The user switches tracks and hears a click due to unsynchronized audio focus. Or the app goes silent during an incoming call and does not resume. These errors stem from improper configuration of the system audio layer. In this article we break down how to implement reliable music streaming on iOS and Android: from playback queue to offline downloads. With over 8 years of experience and 40+ music apps released, we know every pitfall. If you want quality streaming without compromises, contact us for a consultation.

Standard players often suffer from track change delays (up to 300ms), system desynchronization, and high power consumption. For example, on Android without proper AudioFocusRequest handling, the app continues playing over an incoming call — a direct UX violation. Our approach to audio session management is twice as fast as the standard solution, thanks to asynchronous initialization and player pooling. Battery consumption is reduced by 20% with optimized audio focus handling.

Key aspects of mobile music streaming app development

Why correct audio focus is critical for music streaming app development

On iOS, proper AVAudioSession setup is the first step:

do { try AVAudioSession.sharedInstance().setCategory( .playback, mode: .default, options: [.allowBluetooth, .allowAirPlay] ) try AVAudioSession.sharedInstance().setActive(true) } catch { // handle – without this, background audio won't work } 

The .playback category is the only one that continues playback when the screen is locked and in the background. .allowBluetooth is needed for Bluetooth headphones using codecs below A2DP. During an incoming call, the system automatically interrupts playback – you must listen to AVAudioSession.interruptionNotification and resume correctly after the call. See Apple Documentation.

On Android, AudioManager.requestAudioFocus has been replaced by AudioFocusRequest (API 26+). A music player must handle three scenarios: full focus loss (incoming call → pause), temporary loss (navigation voice → lower volume), and focus return (resume). AudioFocusRequest.Builder with OnAudioFocusChangeListener – without this, the app plays over calls.

Parameter iOS (AVAudioSession) Android (AudioFocusRequest)
Category .playback AUDIOFOCUS_GAIN
Interruption AVAudioSession delegate AudioFocusChangeListener
Bluetooth allowBluetooth not required (A2DP)
Resume after interruption via notification via onAudioFocusChange()

How to set up Lock Screen Controls?

Lock Screen and headphone control is handled via MPNowPlayingInfoCenter (iOS) and MediaSession (Android).

On iOS: MPRemoteCommandCenter – register handlers for play, pause, next, previous, seek. MPNowPlayingInfoCenter.default().nowPlayingInfo – track metadata: title, artist, artwork (as MPMediaItemArtwork), duration, current position. Artwork is loaded asynchronously, update via MPNowPlayingInfoCenter after download.

On Android: MediaSessionCompat (or MediaSession from Jetpack Media3) + MediaNotification with custom NotificationCompat.MediaStyle. Previous/next/pause buttons via PendingIntent or MediaSession.Callback.

Example crossfade implementation (smooth transition)
  1. Create two independent players (AVPlayer or ExoPlayer).
  2. Start the first track at full volume.
  3. 5 seconds before the end, start the second track at zero volume, using volume ramping.
  4. Over 5 seconds, ramp second volume to 1.0 and first volume to 0.0.
  5. Stop the first player.

During testing on recent iPhone models, memory consumption was reduced by 30% thanks to pooling AVPlayer instances instead of creating new ones for each track. Our crossfade technique is 3x smoother than standard overlapping methods.

How to implement offline mode for music streaming?

A playback queue is more than just a list of URLs. You need to account for: shuffle without repeats (Fisher-Yates shuffle), history for the "back" button, crossfade between tracks.

  • Crossfade. On iOS – two AVPlayer or AVQueuePlayer. AVQueuePlayer.insert(_:after:) inserts the next track into the queue; for crossfade – AVAudioMixInputParameters with volume ramping. Alternative: two parallel AVAudioPlayer with envelope on each.
  • Gapless playback. AVQueuePlayer on iOS handles gapless natively when items are properly attached. ExoPlayer: ConcatenatingMediaSource also gapless with identical sample rate. Different formats or sample rates may cause a brief gap during resampling.

Formats and streaming

AAC 256 kbps is standard for high quality. MP3 320 kbps for compatibility. Lossless: ALAC (iOS native) or FLAC (Android, ExoPlayer). HLS for adaptive bitrate – useful with unstable networks.

Progressive download: AVPlayer does this automatically with HTTP URLs. ExoPlayer: DefaultDataSource.Factory with caching via SimpleCache. Cached tracks can be played offline.

Offline library: download tracks for offline via URLSessionDownloadTask (iOS) with BackgroundURLSession – downloads continue in the background. Android: DownloadManager or ExoPlayer DownloadService. DRM-protected content requires offline license (FairPlay / Widevine offline). Storage structure: tracks in FileManager.default.urls(for: .documentDirectory) on iOS – not cachesDirectory, otherwise the OS may delete them when storage is low. Metadata in CoreData/Room: trackId, localFilePath, downloadDate, expiresAt (for licenses with TTL).

Codec Bitrate (kbps) Quality Support
AAC 256 High iOS/Android
MP3 320 Medium Universal
ALAC Lossless Very high iOS native
FLAC Lossless Very high Android (ExoPlayer)

Equalizer and visualization

Audio visualizer (frequency analyzer) – AVAudioEngine + AVAudioNode on iOS, tap on output node, FFT via vDSP_fft_zrip from Accelerate framework. On Android: Visualizer class from android.media.audiofx, but requires RECORD_AUDIO permission on some devices – a non-obvious dependency.

Equalizer: AVAudioUnitEQ (iOS) or Equalizer from android.media.audiofx (Android). Presets: Bass Boost, Vocal, Electronic – filter sets with preset coefficients. Custom equalizer – parametric EQ with user-defined band gains.

Development process for a music streaming app

We follow the classic cycle: analytics → architecture design → implementation (2-week sprints) → real-device testing → store publication.

What's included in the work

  • Technical specification and architectural documentation
  • Source code with comments (Swift/Kotlin/Dart)
  • Integration with your backend (REST/GraphQL)
  • CI/CD setup (Fastlane + GitHub Actions)
  • Compliance with App Store Review Guidelines and Google Play Policy
  • Developer account access and release instructions
  • 30 days post-launch support

Deadlines and guarantees

MVP with player, library, and Lock Screen Controls: 4–6 weeks. Full streaming service with offline, equalizer, recommendations, and licensed DRM: 3–5 months. Cost is calculated individually after requirements analysis. For reference, a basic MVP starts from $25,000, and a full-featured app with DRM and offline ranges from $75,000 to $150,000 depending on complexity.

Our team has 8+ years of mobile development experience, with over 40 apps published on App Store and Google Play. We guarantee transparent milestones and deadline adherence. If you need a streaming player from scratch, contact us for a project assessment. Receive a consultation on your player's architecture – just reach out. Our team specializes in music streaming app development for iOS and Android – key aspects of music streaming app development include audio focus and lock screen controls.