Skip to content

[Enhancement]: Duck volume on notification instead of abrupt stop #1967

Description

@gubenkoved

Describe the Feature/Enhancement

Update the ExoPlayer AudioAttributes configuration in PlayerNotificationService.kt so that incoming notification sounds smoothly duck (lower) the audiobook volume in the background instead of completely pausing and rewinding playback.

Specifically, in PlayerNotificationService.kt (lines 407–412):

     val audioAttributes: AudioAttributes =
             AudioAttributes.Builder()
                     .setUsage(C.USAGE_MEDIA)
-                    .setContentType(C.AUDIO_CONTENT_TYPE_SPEECH)
+                    .setContentType(C.AUDIO_CONTENT_TYPE_MUSIC)
                     .build()
     mPlayer.setAudioAttributes(audioAttributes, true)

Why would this be helpful?

  1. Prevents Abrupt Audio Cuts: Currently, when an incoming notification chime arrives (SMS, email, app ping), ExoPlayer forces a complete pause, cutting the audio into silence for several seconds. With CONTENT_TYPE_MUSIC, ExoPlayer smoothly dips the volume for the split-second chime and restores it without interrupting the stream.
  2. Prevents Unintended Auto-Rewind: Because transient focus loss is currently treated as a full pause, when the notification sound ends and ExoPlayer resumes, Audiobookshelf's calcPauseSeekBackTime() interprets it as a pause-and-resume event and jumps backward 3–5 seconds, repeating sentences.
  3. Smooth Listening Experience: Other popular media and audiobook players duck volume during transient system sounds, providing a much smoother listening experience.

Future Implementation (Screenshot)

n/a

Audiobookshelf App Version

Android App - 0.14.0-beta

Current Implementation (Screenshot)

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions