1

enter image description hereI want to hide seekbar view from notification. I tried different solutions(disable chronometer), but it did not work.

I use this code block for disable seek action:

mediaSessionConnector.setEnabledPlaybackActions(PlaybackStateCompat.ACTION_PLAY or
                PlaybackStateCompat.ACTION_PAUSE or
                PlaybackStateCompat.ACTION_STOP or
                PlaybackStateCompat.ACTION_PLAY_PAUSE)

Has anybody idea this case? Thanks,

msevgi
  • 4,479
  • 2
  • 20
  • 29

1 Answers1

1

Just don't set duration in MediaMetadataProvider. My example:

        mediaSessionConnector.setMediaMetadataProvider(player -> {
            if (currentEpisode == null || !currentEpisode.isValid() || realm.isClosed()) {
                return null;
            }

            long duration;
            if (player.getDuration() < 0)
                duration = currentEpisode.getDurationTime();
            else
                duration = player.getDuration();

            MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
            builder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST,
                    currentEpisode.getPodcast().getArtistName());
            builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM,
                    currentEpisode.getPodcast().getCollectionName());
            builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, currentEpisode.getTitle());
            builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, currentEpisode.getImageUrl());
            builder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, currentEpisode.id);

//            if (duration > 0) {
//                builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration);
//            }

            try {
                Bitmap icon;
                if (notificationCover != null) {
                    icon = notificationCover;
                } else {
                    icon = BitmapFactory.decodeResource(getResources(),
                            R.drawable.placeholder);
                }
                builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, icon);

            } catch (OutOfMemoryError e) {
                KLog.e("oom");
            }

            return builder.build();
        });
Mateusz Kaflowski
  • 1,705
  • 1
  • 21
  • 30