Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to hide the seekbar from the default media notification? #265

Open
marcelpallares opened this issue Mar 9, 2023 · 4 comments
Assignees
Labels

Comments

@marcelpallares
Copy link

Hey!

Following the recommendations in #216 we are using a ForwardingPlayer to remove some of the notification commands like skip previous and skip next.

We have another requirement which is to disable the seekbar from any user interaction, and we have achieved that by removing the COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM (which has lately improved as a few releases ago it still let the user move the cursor around the seekbar with a weird behaviour).

Is there any way to hide the seekbar entirely without having to create any custom notification layout? Thank you for your hard work!

@marcbaechinger
Copy link
Contributor

As far as I can tell the notification shows the seekbar if the seek action is available in the legacy session and if the MediaMetadataCompat has an entry with METADATA_KEY_DURATION to define the duration of the media being played.

How this looks like probably depends on the OS version of the device and the target SDK of the app. I don't think there is more the library can do then send these signals or not. The rendering is up to SystemUI on the specific OS.

What API level is your question about? Before or after Android 13/API 33?

@DenysLoboda
Copy link

@marcbaechinger I ran into a similar issue. I need to hide the seekbar when a live session is playing, however I don't have any options to do so. In the new api, there is no way to specify the duration in the metadata, and if you remove the media session from the notification, then it is not displayed correctly on android 13.

@DenysLoboda
Copy link

        val forwardingPlayer =
            object : ForwardingPlayer(player) {
                override fun getAvailableCommands(): Player.Commands {
                    return super.getAvailableCommands()
                        .buildUpon()
                        .remove(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)
                        .build()
                }

                override fun getDuration(): Long {
                    return -1L
                }
            }

        mediaSession = MediaLibrarySession.Builder(
            this,
            forwardingPlayer,
            CustomSessionCallback()
        ).build()

This one works, but I don't think it's the right solution for the problem.

@marcelpallares
Copy link
Author

With that approach, we lose the ability to track the track progress from within the app too (although it's true it hides the seekbar in the notification. It works fine on Android 13 for us @DenysLoboda ).

I will briefly explain our use case to make clear why would we want something like this:
We have a specific use case that runs audio sessions that are split into multiple parts, but when played together they feel like one single track. We also sometimes ask for some info to the user between files, so they cannot manually skip to the real end of a full session.

With the current approach, the user sees a seekbar in the notification and the current audio file progress, which ends up in a weird experience of showing the notification seekbar progress being reset every time the app switches audio files within one single session. It would be nice to be able to hide the seekbar and still be able to retrieve the track progress from the player from within the app (as we accumulate all the audio file durations to show the real session progress inside the app).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants