现阶段通知中心播放暂停切换功能已实现,但是上下一曲功能暂时消失,需要后续优化,这个commit是snapshot

This commit is contained in:
2026-08-21 22:58:44 +08:00
parent 94a4906671
commit 89c4ba8191
5 changed files with 201 additions and 156 deletions
+3
View File
@@ -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);
}
});