Skip to content

Commit dc32ed3

Browse files
committed
feat: add Sonos favorites playlists support
Add support for browsing and playing Sonos favorite playlists/albums directly from the TUI. Features: - Fetch and display favorite playlists from Sonos speakers - Two-view interface: Queue (1) and Favorites (2) - Navigate favorites with arrow keys (up/down or j/k) - Play favorites by pressing Enter - Support for various playlist types including YouTube Music - Optimized state updates with caching to prevent UI hangs - Batch command processing to improve responsiveness Implementation details: - Added FavoritePlaylist struct to represent Sonos favorites - Implemented ContentDirectory browsing via UPnP actions - Added ViewMode enum for switching between Queue and Favorites views - Enhanced SpeakerState with favorites list and navigation state - Improved command handling with batching and state caching - Added proper XML parsing for Sonos playlist metadata Technical notes: - Uses Arc<TrackInfo> and Arc<Vec<Track>> for efficient state sharing since sonor crate types don't implement Clone. Arc allows cheap cloning via reference counting instead of expensive data duplication on every state update (which happens every second).
1 parent 8e3e487 commit dc32ed3

3 files changed

Lines changed: 428 additions & 31 deletions

File tree

src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ pub enum State {
1616
Connecting,
1717
}
1818

19+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20+
pub enum ViewMode {
21+
Queue,
22+
Favorites,
23+
}
24+
25+
#[derive(Debug)]
26+
pub enum Direction {
27+
Up,
28+
Down,
29+
}
30+
1931
#[derive(Debug)]
2032
pub enum Action {
2133
Play,
@@ -25,6 +37,9 @@ pub enum Action {
2537
NextSpeaker,
2638
PrevSpeaker,
2739
VolAdjust(i16),
40+
SwitchView(ViewMode),
41+
NavigateFavorites(Direction),
42+
PlayFavorite(usize),
2843
Nop,
2944
}
3045

0 commit comments

Comments
 (0)