在通知生成器中使用setProgress不能与媒体样式通知一起使用

问题描述 投票:1回答:1

我正在尝试在NotificationBuilder上使用.setProgress(),但如果我使用MediaStyle,似乎pogressBar不会出现:

NotificationCompat.Builder builder = new NotificationCompat.Builder(this,CHANNEL);

builder
  .setSmallIcon(R.drawable.logo)
  // more configuration
  .setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle()
               .setShowActionsInCompactView(1)
               // more config
               .setMediaSession(mediaSession.getSessionToken()))

if(isBuffering){
  builder.setProgres(0,0, true);
}

如果删除.setStyle,进度条将按预期显示,但使用MediaStyle则不会。

有人知道是否有使两者兼容的方法吗?

谢谢

android android-notifications android-notification.mediastyle
1个回答
0
投票

相同的问题,现在我可以在搜索栏中设置最大持续时间

    mMediaPlayer?.setOnBufferingUpdateListener { mp, percent ->
        if (percent == 100){
            val mediaMetadata = MediaMetadata.Builder().putLong(MediaMetadata.METADATA_KEY_DURATION, mp.duration.toLong()).build()
            mediaSession.setMetadata(MediaMetadataCompat.fromMediaMetadata(mediaMetadata))
            return@setOnBufferingUpdateListener
        }
    }

但是缓冲完成后会出现,很quite脚

© www.soinside.com 2019 - 2024. All rights reserved.