现阶段通知中心播放暂停切换功能已实现,但是上下一曲功能暂时消失,需要后续优化,这个commit是snapshot
This commit is contained in:
@@ -287,18 +287,21 @@ class _QTPlayerAppState extends State<QTPlayerApp> {
|
||||
'🎨 [QTPlayerApp] build #$_buildCount ${stopwatch.elapsedMilliseconds}ms');
|
||||
|
||||
// 监听歌曲变化,更新通知栏
|
||||
// main.dart 中 build 方法里的这部分
|
||||
final audioService = context.watch<AudioService>();
|
||||
final handler = context.read<AudioPlayerHandler>();
|
||||
final song = audioService.currentSong;
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (song != null) {
|
||||
// ⭐ song 不为空时才调用
|
||||
handler.updateNotification(
|
||||
id: song.id,
|
||||
title: song.title,
|
||||
artist: song.artist,
|
||||
);
|
||||
} else {
|
||||
// 清空通知
|
||||
handler.mediaItem.add(null);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user