android-media3-exoplayer

Installation
SKILL.md

Android Media3 & ExoPlayer 🎬

Handling streaming audio, video playback, and Picture-in-Picture.

⚡ When to Use

  • When asked to build video players, music streaming services, or complex media apps.

🏗️ Core Rules / Pillars

1. Migrating to Media3

  • Pattern: com.google.android.exoplayer2 is fully deprecated. You MUST use androidx.media3:media3-exoplayer.
  • Implementation: Instantiate the ExoPlayer.Builder(context).build() and strictly manage its lifecycle, hooking it to Compose's DisposableEffect to trigger player.release() when leaving the screen.

2. Audio Focus & Background Playback

  • Pattern: If building a music app, you MUST use MediaSession connected to a Foreground Service.
  • Implementation: Request Audio Focus automatically using Media3's player.setAudioAttributes(..., handleAudioFocus = true) so the player pauses gracefully when a phone call comes in.

🚧 Critical Anti-Hallucination Guards

  • Trap: Do not hallucinate MediaBrowserServiceCompat. Media3 replaces the entire legacy MediaSessionCompat stack with a unified MediaSessionService.
Installs
19
GitHub Stars
11
First Seen
Aug 6, 2026