Straw phase M-2: MediaSession + audio focus + service skeleton
Wraps the existing Activity-owned ExoPlayer in a Media3 MediaSession. Side effects: - Lock-screen media controls (play/pause) - System media notification with play/pause buttons - Audio focus + ducking (other audio dims when straw plays) - Bluetooth + headset hardware-button routing - Plays nicely alongside other media apps' notifications The ExoPlayer is also configured with AudioAttributes (USAGE_MEDIA + CONTENT_TYPE_MOVIE) and handleAudioFocus=true so other apps can request focus correctly (e.g., a phone call ducks/pauses straw). Also scaffolded but NOT yet wired: - PlaybackService extending MediaSessionService — the foundation for true background-after-Activity-kill audio. Manifest entry + deps added (media3-session 1.4.1, concurrent-futures-ktx 1.2.0). The Activity-to-Service migration via MediaController is M-3 work. - POST_NOTIFICATIONS, FOREGROUND_SERVICE, FOREGROUND_SERVICE_MEDIA_PLAYBACK, WAKE_LOCK permissions in manifest. For the user right now: lock the phone while a video plays — media controls appear on the lock screen. Open another app — notification with play/pause sits in the shade. Press a headset's play/pause — straw responds. Pull the home screen — PiP keeps the video floating + audio continues. Full screen-off-background-audio after killing the activity arrives in M-3.
This commit is contained in:
parent
1578de5dbb
commit
7894fe5a4d
4 changed files with 98 additions and 2 deletions
|
|
@ -106,4 +106,8 @@ dependencies {
|
|||
implementation("androidx.media3:media3-exoplayer-dash:1.4.1")
|
||||
implementation("androidx.media3:media3-exoplayer-hls:1.4.1")
|
||||
implementation("androidx.media3:media3-ui:1.4.1")
|
||||
// Media3 session — MediaSessionService for background audio + lock-screen controls.
|
||||
implementation("androidx.media3:media3-session:1.4.1")
|
||||
// Guava ListenableFuture support for awaiting MediaController connect.
|
||||
implementation("androidx.concurrent:concurrent-futures-ktx:1.2.0")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue