By Maryna Poplavska, Lead Project Manager · Last updated 30 November 2026
Music streaming app architecture is not one design. A catalog app (listeners play stored tracks), a live audio broadcast (one source, many listeners, in step with an event) and real-time interactive music (people playing or teaching together) have different latency budgets, different protocols and different mobile problems. Choose the shape before the stack.
This guide maps each shape to its protocols, codecs, mobile behavior and latency limits, from IETF, W3C, Apple, Android and peer-reviewed texts read 30 November 2026. We have built an example of each shape; our cases say what each one does and doesn’t cover. The licensing section is a pointer, not legal advice.
Key takeaways
- Decide the shape before the stack. Catalog, live broadcast and real-time music are different architectures, not settings of one.
- A catalog typically runs on HTTP and a CDN; its hard parts sit on the phone: gapless transitions, background playback and offline downloads with a license check.
- HLS scales live audio through HTTP caching but trails the event. Low-Latency HLS is specified in an Internet-Draft, yet Apple documents it and Android’s Media3 plays it. WebRTC fits near-instant listening, sync to a screen and talk-back.
- WebRTC capture defaults suit speech. For music, switch off echo cancellation, noise suppression and auto gain, and have the receiver signal Opus stereo.
- Lessons and playing in time are different bars. For Sirius, a European lesson platform we built, the target for music instruction was under 300 ms round trip; in a lab piano-duet study, tempo held at 20 ms of added one-way delay, sped up at 10 and slowed at 40, on top of the rig’s own 25–35 ms.
Product owner or founder? Jump to which shape you are building and what licensing involves. Engineer? Start at your shape: catalog, live broadcast or real-time music.
Which shape of audio product are you building?
One of three: catalog, broadcast or real-time session. Each gives the clock to a different owner, and the clock decides the protocol. The framework is ours, not a standard.

| Shape | Examples | Who sets the clock | What latency means | Delivery | Main device problem |
|---|---|---|---|---|---|
| On-demand catalog | Music store, subscription catalog, audiobooks | The listener’s player | Startup time, not delay | Files or adaptive HTTP (HLS, DASH) from a CDN | Gapless, background play, offline |
| Live broadcast | Radio, concerts, sports commentary | The source, or an event the listener also watches | Trailing the source is often fine, unless audio must match a screen | HLS or Low-Latency HLS; WebRTC when near-instant | Sync with a second feed; mobile networks |
| Real-time interactive | Lessons, rehearsals, jam sessions | Nobody: every participant is a source | Tens to hundreds of milliseconds, both ways | WebRTC | Speech processing, echo, headphones |
Rules of thumb:
- If listeners press play on something that already exists, build a catalog.
- If the source is happening now and listeners just listen, build a broadcast.
- If the listeners are also the performers, build a real-time session.
Decide before you build:
- Rights first. Confirm them with counsel before you fix the architecture: territories, offline, ads and takedown terms set what you build.
- DRM. Ask your licensors before you build offline playback.
- Shape. Catalog, broadcast or real-time.
- Least capable device. The oldest phone, browser or headset you must support.
For the general line between HTTP streaming and WebRTC, see our post on when WebRTC is mandatory and when it’s overkill; this guide applies it to audio.
How do you build an on-demand music catalog?
A catalog typically stores encoded files and serves them over HTTP through a CDN; its hard parts are gapless, background and offline playback on the phone. Spec and platform text read 30 November 2026.
What does the delivery pipeline look like?
The pipeline transcodes each lossless master into a few codec and bitrate renditions, packages and stores them, and serves them from a CDN. RFC 8216, the HLS specification (an Informational RFC, Independent Submission, August 2017), names the two properties a catalog needs: a receiver can “adapt the bit rate of the media to the current network conditions”, and HLS “offers compatibility with large-scale HTTP caching infrastructure to support delivery to large audiences.”
Written around video, it also carries audio-only renditions: RFC 8216 defines packed audio for AAC, MP3, AC-3 and Enhanced AC-3; audio also travels in fragmented MP4.
Our explainer on VOD streaming covers the on-demand model.
Which codec: AAC, Opus or FLAC?
In our reading, pick by device support, then bandwidth. We read no listening tests, so nothing here ranks sound quality.
| Codec | Standard | What the primary texts say | Where it fits (our reading) |
|---|---|---|---|
| AAC | ISO/IEC 13818-7, cited by RFC 8216 | Apple’s HLS authoring spec (rule 2.3, which Apple marks as amended): “Stereo audio in AAC, HE-AAC v1, or HE-AAC v2 format MUST be provided.” | The baseline rendition for Apple devices |
| Opus | RFC 6716, IETF Standards Track (2012) | “Opus supports all bitrates from 6 kbit/s to 510 kbit/s.” Required in WebRTC endpoints (RFC 7874); not listed in Apple’s HLS authoring spec | Real-time paths; on-demand where your players support it |
| FLAC | RFC 9639, IETF Standards Track (2024) | Codes audio “without losing information”; Apple lists it among stereo codecs for HLS (rule 2.2); Android’s Media3 plays it | A lossless tier, with larger files |
Why is there a gap between tracks, and how do you get gapless playback?
Usually the gap is encoder padding, not the network. Apple’s Preparing Audio for HTTP Live Streaming explains that AAC adds leading audio to prime the encoder (the “priming duration”), and for CMAF (the Common Media Application Format) recommends an edit list box (elst) that places it before time 0. Formats that support it record how many samples to trim at each end; Android’s Media3 exposes them as encoderDelay and encoderPadding.
Our reading: a player that ignores these values plays a gap or click between tracks; a gapless player trims encoder delay and padding, and decodes the next track before the current one ends. Media3 says “Transitions between items in a playlist are seamless”; in our reading, that holds only when the data is right. No Apple page we read names a gapless playback API, so test iOS playback on live and classical albums.
How does background audio work on iOS and Android?
iOS. Apple lists “Locked device in iOS silences app audio” among the default audio session behaviors. To keep playing, set the AVAudioSession category to playback, enable the Background Modes capability with “Audio, AirPlay, and Picture in Picture” (the audio value of UIBackgroundModes), and wire lock-screen controls through MPRemoteCommandCenter and MPNowPlayingInfoCenter.
Android. Media3’s background playback guide puts the player and its media session “inside a separate Service”: a MediaSessionService (or MediaLibraryService for a library), running as a mediaPlayback foreground service. The documented failure mode: after “more than 10 minutes” paused, stopped or failed without user interaction, the service leaves the foreground state “so it can be destroyed by the system.” In our view, resume should rebuild the session.
How do offline downloads and license checks work?
Offline playback is three things teams often conflate:

- The file on disk.
AVAssetDownloadTaskon iOS; aDownloadServicesubclass on Android, whose guide warns: “It’s important that you don’t try to read files directly from the download directory.” - The license that decrypts the file, with an expiry. On iOS,
AVPersistableContentKeyRequestandmakeSecureTokenForExpirationDate; on Android,OfflineLicenseHelper, a “Helper class to download, renew and release offline licenses.” - Storage management. Media3 downloads can wait for a network type, an idle device or a charger. Neither platform sets a storage budget for you; that is product design.
Apple approves FairPlay production credentials only if the requesting team “provides a streaming service to consumers”, not for third-party accounts acting for content owners or licensees, so in our reading the service operator holds them, not its contractor.
Whether you need DRM at all is up to your rights holders (our reading); our guide to building a video streaming platform covers how DRM systems work.
How do you stream live audio to a large audience?
Use HLS when listeners can trail the event, and WebRTC when listening must be near-instant, synced or two-way. Spec and platform text read 30 November 2026.
When is HTTP live streaming enough?
When listeners can trail the source: radio, concerts, commentary nobody compares with a picture. HLS fans out through CDNs, which cache and reuse the media segments while the live playlist keeps changing, and it trails the live edge by design. RFC 8216: “the client SHOULD NOT choose a segment that starts less than three target durations from the end of the Playlist file.” Apple’s Low-Latency HLS documentation is plain about the trade: “Historically, HLS has favored stream reliability over latency.”
Low-Latency HLS is defined in the HLS 2nd Edition Internet-Draft (draft-pantos-hls-rfc8216bis-22), not in RFC 8216. Revision 22 is marked “Expires: 2 November 2026”; its datatracker page, read 30 November 2026, shows it “Sent to the RFC Editor” but still an “Active Internet-Draft”, not a published RFC. It combines partial segments, blocking playlist reload and preload hints, because “a Segment cannot be distributed until it has been completely encoded and packaged.”
Apple says the mode “lowers video latencies over public networks into the range of standard television broadcasts”. Apple’s HLS Authoring Specification sets configuration values: “The RECOMMENDED Part Target Duration is one second”, with PART-HOLD-BACK at least three times that. No source we read gives an end-to-end figure, and neither do we. Android’s Media3 supports Apple’s Low-Latency HLS.
When does WebRTC win for audio?
In our view, in three cases: the listener must hear the source near-instantly (an auction, a live Q&A), the audio must stay locked to another feed, or listeners talk back. The cost is structural: a CDN reuses one cached HTTP segment across many listeners; each WebRTC listener holds a media-server session. Our post on what WebRTC costs CTOs covers that side.
From our HearSports delivery: “Stripping the video track does not automatically make things simpler. Audio is more sensitive to jitter and packet loss”.
How do you keep live audio in sync with something else?
The hard case: the listener watches a TV or third-party stream that runs late by an amount your servers cannot see. Three options, in our reasoning:
- A shared event timeline plus a user offset. HearSports users tap a button when they see a reference event, such as kickoff, and the platform calculates their delay.
- Source timestamps aligned on the client, when you deliver both the audio and the picture. As our HearSports case puts it: “When you control both sides of the stream, you set the clock.” In HLS, the
EXT-X-PROGRAM-DATE-TIMEtag “associates the first sample of a Media Segment with an absolute date and/or time” (RFC 8216). - Accepted drift, for background listening.
| Option | Fan-out | Talk-back | Sync with another feed | Main cost driver |
|---|---|---|---|---|
| HLS | CDN | No | Coarse offset per user | Encoding, storage, CDN egress |
| Low-Latency HLS | CDN, if it supports the features | No | Offset per user | As HLS, with more frequent requests |
| WebRTC | A media-server session per listener | Yes | Timestamps plus calibration | Media servers per concurrent listener |
Our framework; check your vendor’s current documentation.
Building a live audio feed? Our live streaming app development page shows the live products we build, HearSports among them; book a free call to talk through your product.
What changes when people make music together over the network?
Real-time music needs WebRTC’s speech processing off, Opus in stereo and a delay budget the music survives. Spec text read 30 November 2026.
Why does WebRTC sound bad for music by default?
Because the capture pipeline is built for a talking human:

- Echo cancellation is on. The W3C Media Capture and Streams spec (a Candidate Recommendation Draft, 19 November 2026, still a work in progress) notes that “User Agent implementations tend to use the following default values” with
RTCPeerConnection, including “echoCancellation set to true”. - Gain control is meant for speech. RFC 7874 (IETF Standards Track, 2016), WebRTC’s audio requirements: “For music- or desktop-sharing applications, the level SHOULD NOT be automatically adjusted, and the endpoint SHOULD allow the user to set the gain manually.”
- Echo cancellation should be switchable for music. The same RFC says endpoints “SHOULD allow the entire AEC and/or the nonlinear processing (NLP) to be turned off for applications, such as music, that do not behave well with the spectral attenuation methods typically used in NLP.”
No source we read says noise suppression is on by default, so read back what each browser applies. In our engineering view, all three stages clean up speech and can treat a held note or a decaying chord as noise, echo or a level to correct.
iOS apps have the same trap: the voiceChat audio session mode “optimizes the device’s tonal equalization for voice”, and Apple’s voice-processing I/O unit adds “automatic gain correction”; in our reading, a music app should not use them for performance audio.
How do you configure capture and Opus for music?
The W3C spec defines echoCancellation, autoGainControl, noiseSuppression, channelCount, sampleRate and latency as audio constraints, and says it is sometimes desirable to turn gain control and noise suppression off “so that the audio is not altered.” An illustrative request:
// Illustrative. Constraints are requests: read back what was applied.
const stream = await navigator.mediaDevices.getUserMedia({
audio: {
echoCancellation: false,
noiseSuppression: false,
autoGainControl: false,
channelCount: 2
}
});
const settings = stream.getAudioTracks()[0].getSettings();
MDN notes that the browser “will not fail if this can’t be done” unless you use exact, so check getSettings() per browser.
echoCancellation also takes the value remote-only, and the spec’s example is a music lesson:
“One example is a remote music class, where a student plays an instrument together with some accompaniment produced by a local application. In this case, the application requires audio coming from the remote participant (i.e., the teacher) to be cancelled in order to avoid echo, but also requires that the accompaniment not be cancelled since the music teacher on the remote side needs to hear it together with the sound from the instrument.”
We did not read browser support for remote-only; check your targets.
For Opus, RFC 7587 (IETF Standards Track, 2015) sets the session parameters. An illustrative fragment from one endpoint that wants to receive stereo music and will send it (our example, not the RFC’s; each parameter has a direction; every parameter name is from RFC 7587, and ptime is its own SDP attribute, not an fmtp parameter):
a=rtpmap:101 opus/48000/2
a=fmtp:101 stereo=1; sprop-stereo=1; maxaveragebitrate=128000
a=ptime:20
- Stereo is the receiver’s call. The
rtpmapline always readsopus/48000/2; that is signaling, not stereo. For thestereoparameter, “the default is 0 (mono)”, and a sender to a single destination must not send stereo when the receiver signals 0, so two-channel capture alone does nothing.sprop-stereo=1says this endpoint, as a sender, is “likely to produce stereo audio”. - Bitrate.
maxaveragebitrateis “the maximum average receive bitrate” this endpoint will take, so it caps what the other side sends; RFC 6716 gives “64-128 kbit/s for FB stereo music” at 20 ms frames. A value in that range is our starting point, not a rule. - FEC and DTX. RFC 7587 says “The voice mode of Opus allows for embedding in-band Forward Error Correction (FEC)”, and
useinbandfecis “only a preference”. RFC 6716 says “the MDCT layer should be used for music signals”, so for music, don’t count on in-band FEC (our reading). Leaveusedtxat 0; RFC 7587 recommends continuous transmission “unless constraints on available network bandwidth are severe”.
With echo cancellation off, remote audio must not reach the microphone, so open-microphone music needs headphones (our reading; RFC 7874 says endpoints should be able to “detect the presence of a headset and disable echo cancellation”).
How low does latency need to be for lessons, and for playing together?
A lesson is turn-taking: the teacher listens, stops, demonstrates. The Sirius challenge list states “sub-300ms round-trip latency is the target for music instruction”; that is a target, not a measurement.
Playing in time is harder. A 2021 peer-reviewed study in Frontiers in Psychology seated 12 pianist pairs in adjacent lab rooms with MIDI keyboards and headphones, and added 10, 20 or 40 ms of one-way delay to each partner’s sound, on top of the equipment’s own latency (about 25–35 ms). At 10 ms the pairs sped up, at 20 ms they held tempo, and at 40 ms they slowed.
These are lab delays, not internet measurements. In our reading, on a roughly symmetric path one-way delay is about half a round trip, so the 300 ms target and the 10 to 40 ms figures measure different things; lessons over WebRTC work, and tight ensemble playing over the public internet is a research-grade problem we would not promise.
Where the delay comes from: the codec, which RFC 6716 describes “with algorithmic delays ranging from 5 ms to 65.2 ms”; then, in our view, device capture and output buffers, the network path, and Bluetooth headphones, which add delay you cannot control. Test with wired ones.
What topology, and what about recording?
For a 1:1 lesson, direct peer-to-peer can keep the media path short (a TURN relay adds a hop); for group classes, an SFU replaces a mesh (each participant sends an uplink and holds a connection per peer) with a single uplink to the server (our reading). Our post on low-latency live learning works through P2P, SFU and MCU by class size. Recording adds consent and retention decisions; make them before you record.
Which shape did each of our projects cover, and where does each case stop?
We built one project per shape, and none is a full music-streaming subscription service. Of our 50+ successful video/voice projects, these three map to this guide, each with its limit:
- On-demand: Pedestal artist content marketplace. Its React Native app has “audio streaming with background play, gapless album transitions”, and offline listening uses “pre-validated access tokens that work without connectivity, local storage budgeting that warns before filling the device”. Limit: artists sell direct to fans, so it is not a subscription catalog; the page names no DRM system.
- Live broadcast: HearSports live audio commentary. Commentary tracks over live sports, on Janus WebRTC and a native iOS app, synced by “a timestamp-alignment system that maps commentary audio to the live event timeline”. Limit: speech, not music. We tuned “packet loss concealment for speech-like content rather than music”, and users calibrate their own delay by tapping.
- Real-time lessons: Sirius music education. Live instrument lessons on a platform built to connect over 8,000 educators with students, with “Opus profiles (48kHz sampling, higher bitrate, disabled noise suppression)”, so that “Teachers could hear whether a student’s C-sharp was slightly flat”. Limit: lessons, not ensemble playing; the page names noise suppression, not echo cancellation or gain control.
Between them, they cover one hard part of each shape: background and offline playback on a phone, audio locked to a live event, and Opus profiles with noise suppression off.
Build, assemble or buy? In our view, it turns on which layer is your product: buy hosted catalog or HLS services if your edge is the content; assemble a media server and player SDK if your edge is the app; build when offline playback, a sync engine or music capture settings set you apart.
If your product needs more than one of these shapes, that is the conversation to bring to the call.
What does licensing involve, and when do you ask counsel?
Settle rights before architecture: what your licensors allow decides what you must build. Streaming a recording uses two copyrights. The US Copyright Office’s Circular 56A (revised 03/2021): “Sound recordings and musical compositions are considered two separate works for copyright purposes.”
For compositions, Title I of the Music Modernization Act “establishes a blanket licensing system for digital music providers to make and distribute digital phonorecord deliveries (e.g., permanent downloads, limited downloads, or interactive streams)”. The Office designated the Mechanical Licensing Collective (The MLC) to collect and distribute mechanical royalties under Title I. The Copyright Royalty Board sets statutory rates; the Office’s licensing page points there “for information on determination of rates and terms for the copyright statutory licenses”.
Our reading, for counsel to confirm: the blanket license covers only the composition’s mechanical right, not its public performance right; the recording is licensed separately. Outside the US, ask counsel about your territory’s collecting societies.
Questions counsel will ask engineering (our reading):
- Which territories, and how is location enforced?
- Is offline allowed, for how long, and with what license check?
- Ad-supported, paid, or both?
- Can users upload, and how fast can you take content down?
Not legal advice; this guide covers the engineering.
FAQ
Which protocol should you use for streaming audio: HLS or WebRTC?
It depends on the shape: HLS for a catalog and for broadcasts that can trail the event; WebRTC for near-instant listening, sync to a screen or playing together. See which shape you are building.
How do music apps keep playing when the screen is locked?
On iOS, the playback audio session category plus the audio background mode; on Android, a MediaSessionService running as a mediaPlayback foreground service.
Can you use WebRTC for live music, such as lessons or rehearsals?
For lessons, yes: switch off echo cancellation, noise suppression and auto gain, have the receiver signal stereo, and use headphones (configuration). Rehearsing in tight time is limited by delay; in the lab duet study, tempo held at 20 ms of added one-way delay, sped up at 10 and slowed at 40, on top of the rig’s own 25–35 ms.
Do I need DRM for a music app?
It depends on your rights holders’ terms (our reading). Apple notes that a player typically supports a single protection system, so serving Apple and Android devices can mean two systems, not two sets of files: Apple ties FairPlay to the cbcs scheme, and Android’s Media3 lists Widevine cbcs from Android 7.1 (API 25) for DASH and fMP4 HLS. In our reading, with compatible CMAF packaging that can be one cbcs-encrypted file set with two license paths; verify device support with each platform and licensor. Ask the licensor and your counsel.
Building a music, live audio or lesson product? Book a free 30-minute call with a Trembit engineer. Bring your product shape (catalog, live broadcast or interactive), the least capable listener device you must support, and whether offline playback is a requirement. We will map the delivery path and flag where each decision costs you. No deck, no pitch.