android 10 seek bar on notification

十年热恋 提交于 2020-05-14 01:00:18

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/59516981/android-10-seek-bar-on-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!