KotlinMedia3 ExoPlayerJetpack ComposeDagger HiltCoil

AudioFlux - Hi-Fi Audio Streaming & Player

An ultra-fluid Android music player with Jetpack Media3 ExoPlayer, dynamic color theming, and offline audio caching.

2024-01-20•2 min read
AudioFlux - Hi-Fi Audio Streaming & Player

AudioFlux: Modern Android Audio Streaming

AudioFlux is an open-source Android music streaming client engineered around the latest Jetpack Media3 (ExoPlayer) APIs. It delivers lossless audio streaming, seamless background playback, Bluetooth AVRCP control, and dynamic Material You dynamic palette extraction from album artworks.


🎧 Architecture & Modern Media3 Implementation

Android audio apps often suffer from service lifecycles, notification out-of-sync bugs, and Android Auto incompatibility. AudioFlux solved this using the official Media3 architecture:

  • MediaSessionService: Hosts a singleton MediaSession that securely connects with system media controllers, lockscreen widgets, and Android Auto head units without custom IPC boilerplate.
  • Dynamic Palette Extraction: Used AndroidX Palette to dynamically extract dominant and vibrant color swatches from album art bitmaps, applying smooth gradient transitions to the Compose player screen.
  • LRU Audio Segment Caching: Configured SimpleCache with LeastRecentlyUsedCacheEvictor to guarantee smooth, jitter-free audio playback even when users switch between Wi-Fi and unstable mobile connections.
// MediaSessionService Configuration
class AudioPlaybackService : MediaSessionService() {
    private var mediaSession: MediaSession? = null

    @Inject
    lateinit var player: ExoPlayer

    override fun onCreate() {
        super.onCreate()
        mediaSession = MediaSession.Builder(this, player)
            .setCallback(CustomMediaSessionCallback())
            .build()
    }

    override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaSession? {
        return mediaSession
    }

    override fun onDestroy() {
        mediaSession?.run {
            player.release()
            release()
            mediaSession = null
        }
        super.onDestroy()
    }
}

⚡ Performance Optimization

  • Bitmap Memory Caching: Employed Coil with custom memory constraints to ensure hi-res cover art doesn't induce OutOfMemoryError on low-RAM devices.
  • Audio Equalizer DSP: Connected Android AudioEffect engine directly to the audio session ID for custom 10-band graphic equalizers and bass boosting.
Available for New Projects & Roles

Let's Build Something Extraordinary

Whether you need to architect a new Android app from scratch, migrate your codebase to Jetpack Compose, or optimize performance for millions of users, I'd love to connect.

Jakarta, Indonesia (Open to Remote)
Direct Email Address
anzel.engineer@gmail.com
Send Email