SpotControl is a modern WPF desktop application for controlling Spotify playback on your account. It demonstrates C# and WPF concepts, including:
- OAuth authentication with Spotify
- MVVM (Model-View-ViewModel) architecture for clean separation of UI and logic
- Multithreading for responsive UI and background updates
- Exception handling for robust user experience
- Inheritance and class design for extensibility
- Data binding for dynamic UI updates
Requires .NET 6.0 or later, Spotify Premium, and a Spotify Developer app.
- Clone the repository
- Open in Visual Studio 2022+
- Restore NuGet packages
- Run the application
- Login to Spotify when prompted
Or download the latest release from the Releases page.
- Authenticate with Spotify using OAuth
- Display currently playing track info (title, artist)
- Basic playback control Play, Pause, Next, Previous
- Responsive WPF interface
- Volume control slider
- Track progress bar with seek functionality
- Shuffle and repeat toggle
- Dynamic UI updates using MVVM and data binding
- Exception handling for network/API issues
- Playback art (album cover)
Search for songs/playlists and play themDisplay playlists and allow selectionKeyboard Hotkey media key integrationSystem tray minimization with pop-up notificationsTheme switching (light/dark mode)
- Model: Spotify API data (track, playback state)
- View: WPF XAML files (
MainWindow.xaml,LoginWindow.xaml) - ViewModel:
PlayerViewModelmediates between Spotify data and the UI, exposing properties and commands for binding.
MediaController(abstract base class) defines playback control methods.SpotifyServiceinherits fromMediaControllerand implements Spotify-specific logic.BaseViewModel(abstract base class) provides common functionality for all ViewModels, including property change notifications.MediaViewModel(abstract class) inherits fromBaseViewModeland defines properties and commands for media control.PlayerViewModelinherits fromMediaViewModeland implements Spotify-specific logic.
- Each user action (play, pause, next, previous, seek, set volume, toggle shuffle/repeat) is encapsulated in a method, often exposed as an
ICommandfor WPF binding. - Methods like
UpdateTrackInfoAsyncfetch and update UI data.
- Background polling for track info and progress uses
whileloops in async tasks to periodically update the UI.
- Track and artist names are handled as strings.
- Artist lists are joined into a single string for display.
- Uses
Task.Runandasync/awaitfor background polling and API calls, keeping the UI responsive. - Cancellation tokens allow safe stopping of background threads.
- All network and API calls are wrapped in try/catch blocks to handle errors gracefully and inform the user.
