Feature proposal
In some Android systems, there is a feature for displaying lyrics in the status bar, such as Flyme OS.

To integrate this feature, you need to add two flags in the notification.flags and set the current lyrics to the ticker.
Motivating use case(s)
The link https://juejin.cn/post/7097415319643226125 is a tutorial I found about integrating status bar lyrics. I apologize that it's in Chinese, and you may need to use a translation tool.
In addition, I have also tried using flutter_local_notifications to send notifications, but it displays a notification in the notification bar at the same time. If I use the same ID as audio_service (1124), updating the status bar lyrics will replace audio_service's notification.
here is the code:
/// Flyme 状态栏歌词 TICKER 一直显示
const flagAlwaysShowTicker = 0x1000000;
/// 只更新 Flyme 状态栏歌词,不更新封面等
const flagOnlyUpdateTicker = 0x2000000;
class LocalNotification {
static final FlutterLocalNotificationsPlugin instance =
FlutterLocalNotificationsPlugin();
static Future<void> init() async {
const initializationSettingsAndroid =
AndroidInitializationSettings('notify_icon');
const initializationSettings =
InitializationSettings(android: initializationSettingsAndroid);
await instance.initialize(initializationSettings);
// 如果开启了系统级状态栏歌词,则监听歌词变化
if (AppSettings.player.enableSystemStatusBarLyric) {
PlayerManager.lyricLineChangedStream.listen((event) {
final currentAudio = PlayerManager.currentAudio;
String title =
CommonUtil.getSongTitle(currentAudio?.title, currentAudio?.artist);
showLyric(event?.currentLine ?? title);
});
}
}
static Future<void> showLyric(String lyric) async {
AndroidNotificationDetails androidNotificationDetails =
AndroidNotificationDetails('channel_id', 'title',
showWhen: false,
channelDescription: 'description',
playSound: false,
ongoing: PlayerManager.getPlayer().isPlaying,
additionalFlags: Int32List.fromList(
[flagAlwaysShowTicker, flagOnlyUpdateTicker]),
ticker: lyric);
NotificationDetails notificationDetails =
NotificationDetails(android: androidNotificationDetails);
await instance.show(1124, null, null, notificationDetails);
}
}
Therefore, the only solution is to attach these special parameters to the audio_service notification.
The branch https://github.com/gitbobobo/audio_service/tree/statusbar_lyric is a modification I made on top of audio_service. Its main function is to read the value of current_lyrics from mediaItem.extras and set it to the notification's ticker. Currently, it is not very generic and is for reference only.
Feature proposal
In some Android systems, there is a feature for displaying lyrics in the status bar, such as Flyme OS.
To integrate this feature, you need to add two flags in the notification.flags and set the current lyrics to the ticker.
Motivating use case(s)
The link https://juejin.cn/post/7097415319643226125 is a tutorial I found about integrating status bar lyrics. I apologize that it's in Chinese, and you may need to use a translation tool.
In addition, I have also tried using
flutter_local_notificationsto send notifications, but it displays a notification in the notification bar at the same time. If I use the same ID as audio_service (1124), updating the status bar lyrics will replace audio_service's notification.here is the code:
Therefore, the only solution is to attach these special parameters to the audio_service notification.
The branch https://github.com/gitbobobo/audio_service/tree/statusbar_lyric is a modification I made on top of audio_service. Its main function is to read the value of current_lyrics from mediaItem.extras and set it to the notification's ticker. Currently, it is not very generic and is for reference only.