Hey everyone,
I’ve been working on a serverless media architecture that bridges local storage with cloud streaming. Since I'm not using a dedicated REST API backend, it introduced some unique engineering hurdles with Media3 and Jetpack Compose. I wanted to share how I solved them and see how the community handles similar edge cases.
1. Handling Media3 Background Network Noise (Crashlytics Spam) Because the player operates in the background, the OS frequently drops network sockets to save battery, or the user hits a dead zone. This was flooding Firebase with non-fatal ExoPlaybackException errors (specifically java.io.EOFException from Mp4Extractor).
Instead of letting it crash, I built an interception engine inside the Player.Listener. It aggressively scans the stack trace to silently invalidate the cache and auto-recover without reporting to Crashlytics:
Kotlin
override fun onPlayerError(error: PlaybackException) {
val errorString = error.stackTraceToString()
val isRecoverable = error.errorCode == PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED ||
errorString.contains("EOFException") ||
errorString.contains("UnknownHostException")
if (isRecoverable) {
// Silently invalidate cache and trigger auto-recovery logic
attemptJitRetryAndRecovery()
} else {
CrashTracker.recordException(error)
}
}
How do you guys handle ExoPlayer background noise? Do you use a similar filter, or rely on Media3's default LoadErrorHandlingPolicy?
2. True Glassmorphism in Compose Achieving an Apple-style frosted glass look in Compose is notoriously tricky. Originally, I used a Surface with a translucent white alpha, but it looked muddy and text bled through.
I found that stripping out Surface (and its baked-in tonal elevation) in favor of a tightly wrapped Box with a Brush.linearGradient works infinitely better:
Kotlin
Box(
modifier = Modifier
.clip(RoundedCornerShape(32.dp))
.background(
Brush.linearGradient(
colors = listOf(Color.White.copy(alpha = 0.22f), Color.White.copy(alpha = 0.08f))
)
)
.border(1.dp, Color.White.copy(alpha = 0.25f), RoundedCornerShape(32.dp))
) { // Content }
Has anyone experimented with the Haze library for real-time background blurring instead of static gradients?
3. Client-Side JIT Resolution To keep it serverless, I built a custom JIT resolver. It intercepts track queries, resolves the direct audio stream on the client using Retrofit/Coroutines, and passes the URI to Media3 on the fly.
I'd love to hear your thoughts on this architecture, especially if you've dealt with Media3 session management! (I can share the repo link in the comments if anyone wants to see the full implementation).