Add system notifications for track changes
- Add notify-rust dependency for desktop notifications - Create notification.rs commands module with show_track_notification and show_notification - Register notification commands in lib.rs - Wire up notifications in frontend for all playback scenarios: - Search results playback - Album track playback - Playlist track playback - Queue navigation and auto-advance
This commit is contained in:
1 parent
ddbedf6ab0
commit
ef8feebc45
5 files changed
+101
No files matched your search
@@ -277,6 +277,14 @@
|
||||
durationSecs: track.duration,
|
||||
coverUrl: artwork || null
|
||||
});
|
||||
|
||||
// Show system notification
|
||||
showTrackNotification(
|
||||
track.title,
|
||||
track.performer?.name || 'Unknown Artist',
|
||||
track.album?.title || '',
|
||||
artwork || undefined
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('Failed to play track:', err);
|
||||
showToast(`Playback error: ${err}`, 'error');
|
||||
@@ -350,6 +358,14 @@
|
||||
durationSecs: track.durationSeconds,
|
||||
coverUrl: artwork || null
|
||||
});
|
||||
|
||||
// Show system notification
|
||||
showTrackNotification(
|
||||
track.title,
|
||||
track.artist || selectedAlbum?.artist || 'Unknown Artist',
|
||||
selectedAlbum?.title || '',
|
||||
artwork || undefined
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('Failed to play track:', err);
|
||||
showToast(`Playback error: ${err}`, 'error');
|
||||
@@ -483,6 +499,9 @@
|
||||
coverUrl: track.artwork_url
|
||||
});
|
||||
|
||||
// Show system notification
|
||||
showTrackNotification(track.title, track.artist, track.album, track.artwork_url || undefined);
|
||||
|
||||
// Refresh queue state
|
||||
await syncQueueState();
|
||||
} catch (err) {
|
||||
@@ -653,6 +672,14 @@
|
||||
coverUrl: track.albumArt
|
||||
});
|
||||
|
||||
// Show system notification
|
||||
showTrackNotification(
|
||||
track.title,
|
||||
track.artist || 'Unknown Artist',
|
||||
track.album || 'Playlist',
|
||||
track.albumArt
|
||||
);
|
||||
|
||||
await syncQueueState();
|
||||
} catch (err) {
|
||||
console.error('Failed to play track:', err);
|
||||
@@ -661,6 +688,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
// System Notification for track changes
|
||||
async function showTrackNotification(title: string, artist: string, album: string, artworkUrl?: string) {
|
||||
try {
|
||||
await invoke('show_track_notification', {
|
||||
title,
|
||||
artist,
|
||||
album,
|
||||
artworkUrl: artworkUrl || null
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to show track notification:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Toast Functions
|
||||
function showToast(message: string, type: 'success' | 'error' | 'info' = 'info') {
|
||||
toast = { message, type };
|
||||
|
||||
Reference in new issue
Block a user