android - 如何在 Exoplayer 通知中设置自定义布局和字体?
问题描述
我PlayerNotificationManager
用于在我的应用程序中显示播放通知。一切正常,但我想在通知中使用自定义字体添加我的应用程序徽标。
我通过添加更改了通知上的播放和暂停按钮drawables.xml
。但是找不到更改字体的方法。
那么,如何更改 Exoplayer 提供的默认通知布局和特性呢?
编辑:
我在 Github 上看到了这个问题,它说我们需要扩展PlayerNotificationManager
才能使用自定义布局。但我似乎无法让它工作。
这是我的代码:
private void setPlayerNotificationManager(Player player) {
playerNotificationManager = new PlayerNotificationManager(context, "123", 1234, mediaDescriptionAdapter);
playerNotificationManager.setUseNavigationActions(false);
playerNotificationManager.setUsePlayPauseActions(true);
playerNotificationManager.setRewindIncrementMs(0);
playerNotificationManager.setFastForwardIncrementMs(0);
//playerNotificationManager.setColor(Color.GREEN);
playerNotificationManager.setColorized(true);
playerNotificationManager.setUseChronometer(false);
playerNotificationManager.setSmallIcon(R.drawable.logo);
playerNotificationManager.setPlayer(player);
}
解决方案
正如在 repo 上所说,您需要扩展PlayerNotificationManager
您需要创建此类并复制项目中的所有内容,然后按照此链接中的说明添加要使用的布局
您需要在builder
此处添加布局