-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to support custom notification parameters? #1043
Comments
That's interesting. Do you know if this is a standard flag across manufacturers or if there are also other flags by different manufactures that serve the same purpose? I'm asking since I may hard code the flag. I consider this to be in a similar scope to copying media metadata across to the notification such as the current song title. So to implement this within audio_service, the data itself would be added to This obviously updates the entire notification, but I don't think that should be too inefficient, and besides, to make such an app work on devices that don't support the ticker like this, you would probably fall back to updating the title/subtitle anyway which also works the same way. But then it seems like |
Yes, in my app, I am currently using the mediaItem.add() method to update lyrics. As for updating lyrics to the title/subtitle as another user-selectable switch, here is my code for updating the status bar lyrics and notification lyrics: PlayerManager.lyricLineChangedStream.listen((event) {
if (PlayerManager.currentAudio == null || mediaItem.value == null) return;
var displayTitle = CommonUtil.getSongTitle(
PlayerManager.currentAudio!.title,
PlayerManager.currentAudio!.artist);
final lockLyric = AppSettings.player.enableLockLyric;
final statusBarLyric = AppSettings.player.enableSystemStatusBarLyric;
var newMediaItem = mediaItem.value!;
if (lockLyric) {
newMediaItem = newMediaItem.copyWith(
title: event?.currentLine ?? PlayerManager.currentAudio!.title,
artist: event?.currentLine == null
? PlayerManager.currentAudio!.artist
: displayTitle,
);
} else {
newMediaItem = newMediaItem.copyWith(
title: PlayerManager.currentAudio!.title,
artist: PlayerManager.currentAudio!.artist,
);
}
if (statusBarLyric) {
// 开启系统级状态栏歌词后,在extra中添加歌词信息
newMediaItem = newMediaItem.copyWith(
extras: {
...newMediaItem.extras!,
'current_lyrics': event?.currentLine ?? displayTitle,
},
);
} else {
newMediaItem = newMediaItem.copyWith(
extras: {
...newMediaItem.extras!,
'current_lyrics': null,
},
);
}
mediaItem.add(newMediaItem);
}); I tried removing the flagOnlyUpdateTicker flag, and the status bar lyrics, as well as the title/subtitle, can still be updated. Currently, I know that Flyme OS and some quasi-native Android systems like Evolution-X support status bar lyrics. Whether it's a standard feature for different manufacturers is still something I need to wait for my users to try out over a period of time to see if it works. |
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:
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.
The text was updated successfully, but these errors were encountered: