通知中的android 10搜寻栏 [英] android 10 seek bar on notification

查看:54
本文介绍了通知中的android 10搜寻栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道关于Android 10中通知的seekbar功能吗?

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.

我具有正常的通知生成器代码,并且已添加此代码,以使libvlc的"MediaPlayer.Event.Playing"事件中的搜索栏可单击

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.

推荐答案

您需要添加带有白色的小图标.您不应该将图标与其他颜色一起使用.

You need add small icon with white color. You shouldn't use icon with other colors.

NotificationCompat.Builder builder = new NotificationCompat.Builder(service,NOTIFICATION_CHANNEL_ID)
                .setSmallIcon(R.drawable.ic_white)

这篇关于通知中的android 10搜寻栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆