android 10 seek bar on notification

2020-07-26 17:57发布

does anyone know about the seekbar function on notifications in android 10?

I can't seem to get the position indicator to show the current position. the bar is just blank but I can seek the media clicking the bar in the notification.

I have the normal notification builder code and I have added this to make the seekbar clickable in the "MediaPlayer.Event.Playing" event of libvlc

MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder();


metadataBuilder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, mMediaPlayer.getLength());

PlaybackStateCompat.Builder mStateBuilder = new PlaybackStateCompat.Builder()
        .setState(PlaybackStateCompat.STATE_PLAYING,  1, 1.0f)
        .setBufferedPosition(mMediaPlayer.getLength())
        .setActions(
                PlaybackStateCompat.ACTION_PLAY |
                        PlaybackStateCompat.ACTION_PAUSE |
                        PlaybackStateCompat.ACTION_SKIP_TO_NEXT |
                        PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                        PlaybackStateCompat.ACTION_SEEK_TO |
                        PlaybackStateCompat.ACTION_PLAY_PAUSE);


mediaSession.setMetadata(metadataBuilder.build());
mediaSession.setPlaybackState(mStateBuilder.build());

the media playing is about half way but there is no indicator of its position.

notification

1条回答
别忘想泡老子
2楼-- · 2020-07-26 18:24

update: it does appear to be showing the position but it is hard to see when the color of the notification is dark. for some reason the seekbar is not inverting its color based on the notification color.

if anyone comes across this problem make the background of the notification white and look to see if it is tracking the position.

so now i need to figure out how to get the bar to display a light color on a dark background

notification

查看更多
登录 后发表回答