9.0 KiB
Pianobar Helper - Implementation Guide
Overview
This document provides complete implementation details for the Pianobar Helper Windows Forms application.
Architecture
Core Components Created
-
ProfileManager.cs - Backend profile management system
- Handles profile creation, deletion, and configuration
- Stores profiles in JSON format in AppData
- Generates Pianobar config files with credentials
-
PianobarManager.cs - Process lifecycle manager
- Direct
pianobar.exeprocess control - Real-time stdout/stdin communication
- Song metadata parsing
- Event-driven architecture
- Direct
-
OutputManager.cs - Multi-output mechanism handler
- Text file export
- Local web server (JSON endpoint)
- Windows Toast Notifications (placeholder)
- Windows SMTC integration (placeholder)
-
MainForm (Main.cs) - Primary application interface
-
SettingsForm (Settings.cs) - Profile and configuration management
-
StationForm (StationForm.cs) - Station picker interface
Designer File Issues
The Designer files (.Designer.cs) need to be regenerated through Visual Studio's Form Designer. Here's what needs to be done:
MainForm Designer Controls Required
Open Main.cs in the Form Designer and add these controls:
MenuStrip (menuStrip1):
fileToolStripMenuItem- "File" menusettingsToolStripMenuItem- "Settings..." menu itemprofilesToolStripMenuItem- "Profiles" submenu (dynamically populated)
StatusStrip (statusStrip1):
statusLabelLeft(ToolStripStatusLabel) - Connection indicatorstatusLabelCenter(ToolStripStatusLabel) - Alternating profile/station infostatusLabelRight(ToolStripStatusLabel) - Event feed
Buttons:
connect_button- "Connect" button (wire tobtnConnect_Click)disconnect_button- "Disconnect" button (wire tobtnDisconnect_Click)stations_button- "Stations" button (wire tobtnStations_Click)
GroupBox (groupBox1) - "Playback Controls":
btnPlayPause- "Play / Pause" button (wire tobtnPlayPause_Click)btnSkip- "Skip" button (wire tobtnSkip_Click)
Additional Controls:
album_art_picture_box(PictureBox) - For album art displayinfo_table_Panel(TableLayoutPanel) - For song metadata display
SettingsForm Designer Controls Required
Open Settings.cs in the Form Designer and add these controls:
GroupBox (profiles_group_box) - "Profile Management":
selected_profile_label- Label: "Selected profile:"profiles_combo_box_selector(ComboBox) - Profile selector (wire toprofiles_combo_box_selector_SelectedIndexChanged)new_profile_button- "+ New" button (wire tonew_profile_button_Click)delete_profile_button- "Delete" button (wire todelete_profile_button_Click)
GroupBox (profile_configuration_group_box) - "Profile Configuration":
TabControl (profile_config_tab_control):
Tab 1 (outputs_tab_page) - "Outputs":
obs_text_output_check_box- "File output (For OBS / Streaming)"output_label- "Output Folder:"output_folder_text_box(TextBox)output_folder_browse_button- "Browse" (wire tooutput_folder_browse_button_Click)local_web_server_check_box- "Enable Local Web Server"port_label- "Port:"textBox1(TextBox) - Port number inputchk_toast_notifications- "Show Windows Toast Notifications"chkSMTC- "Windows System Media Controls (SMTC)"
Tab 2 (pianobar_override_tab_page) - "Pianobar Config & Auth":
chkOverrideCredentials- "Enable Profile Credentials..." (wire tochkOverrideCredentials_CheckedChanged)txtConfigFilePathLabel- "Config Save Path:"txtConfigFilePath(TextBox)btnBrowseConfigFile- "Browse" (wire tobtnBrowseConfigFile_Click)UsernameLabel- "Username / Email:"txtPianobarUser(TextBox)PasswordLabel- "Password:"txtPianobarPass(TextBox) - Set UseSystemPasswordChar = true
Dialog Buttons:
- Add OK/Cancel buttons and wire appropriately to
btnSave_ClickandbtnCancel_Click
StationForm Designer Controls Required
Open StationForm.cs in the Form Designer and add these controls:
GroupBox (station_list_group_box) - "Available Stations":
search_label- "Search:"textBox1(TextBox) - Search box (wire totextBox1_TextChanged)lstStations(ListBox) - Station list
Buttons:
refresh_button- "Refresh stations" (optional)btnSelectStation- "Select Station" (wire tobtnSelectStation_Click)btnCancelStation- "Cancel" (wire tobtnCancelStation_Click)
Quick Fix Steps
-
Rebuild Designer Files:
- Open Visual Studio
- Open each form (Main.cs, Settings.cs, StationForm.cs) in the Designer
- Right-click the form surface ? "View Code"
- Close and reopen the Designer view
- This should regenerate the Designer files properly
-
Alternative - Manual Constructor Fix: If the Designer files are corrupted, you can temporarily comment out the constructors in the .cs files and let Visual Studio regenerate them.
-
Verify Event Wiring:
- In the Designer, select each control
- In Properties window, click the Events icon (lightning bolt)
- Double-click the appropriate event (e.g., Click, TextChanged)
- This will wire up the event handlers automatically
Usage Instructions
First Run
- Launch the application
- Go to File ? Settings
- Create a new profile (click "+ New")
- Configure output settings (text file, web server, etc.)
- (Optional) Enable credential override and set Pianobar username/password
- Click OK to save
Connecting to Pianobar
- Ensure
pianobar.exeis in your PATH or specify full path - Click "Connect" button
- Status indicator will show:
- ?? Red = Disconnected
- ?? Green = Connected (no outputs active)
- ?? Blue = Connected (outputs active)
Playback Control
- Use "Play / Pause" button to toggle playback
- Use "Skip" button to skip current track
- Click "Stations" to open station picker
Profile Switching
- Go to File ? Profiles
- Select a different profile (checkmark shows active)
- Reconnect to apply new profile settings
Technical Details
Status Bar Behavior
The center status zone alternates every 10 seconds between:
- Profile name display
- Current station display
Output Mechanisms
Text File Output:
- Writes song metadata to specified text file
- Updates on each song change
- Format: Title, Artist, Album, Album Art URL, Timestamp
Web Server:
- Starts HTTP listener on specified port
- Serves JSON at
http://localhost:<port>/ - JSON structure:
{ title, artist, album, albumArtUrl, timestamp }
Toast Notifications & SMTC:
- Currently placeholder implementations
- Requires Windows SDK references to fully implement
- See TODO comments in OutputManager.cs
Pianobar Communication Protocol
The app listens for these patterns in Pianobar output:
- Song metadata: Lines containing "Title:", "Artist:", "Album:", "coverArt:"
- Playing indicator:
|>prefix - Paused indicator:
||prefix - Station selection:
| Station "..."
Troubleshooting
"InitializeComponent does not exist"
- The Designer files need to be regenerated
- Open each form in the Designer view
- Save the forms to regenerate Designer code
"Pianobar is already running"
- Close existing Pianobar instances
- The app detects running processes to avoid conflicts
Config file not generated
- Ensure "Override Credentials" is checked
- Verify config file path is valid
- Check write permissions to the target directory
Web server won't start
- Check if port is already in use
- Try a different port number
- Run as administrator if using port < 1024
Future Enhancements
-
SMTC Integration:
- Add reference to Windows.Media
- Implement SystemMediaTransportControls
- Handle media key events
-
Toast Notifications:
- Add reference to Windows.UI.Notifications
- Implement ToastNotificationManager
- Create custom toast templates with album art
-
Album Art Display:
- Download album art from URL
- Display in
album_art_picture_box - Cache images locally
-
Song Info Display:
- Populate
info_table_Panelwith metadata - Show song progress
- Display station info
- Populate
File Structure
PainoBar Helper/
??? Main.cs # Main form implementation
??? Main.Designer.cs # Main form designer (regenerate)
??? Settings.cs # Settings form implementation
??? Settings.Designer.cs # Settings designer (regenerate)
??? StationForm.cs # Station picker implementation
??? StationForm.Designer.cs # Station designer (regenerate)
??? ProfileManager.cs # Profile management backend
??? PianobarManager.cs # Pianobar process manager
??? OutputManager.cs # Output mechanisms handler
??? Program.cs # Application entry point
??? IMPLEMENTATION_GUIDE.md # This file
Contact & Support
For issues or questions about this implementation, refer to the inline code comments or the method documentation in each class.
All public methods include XML documentation comments explaining their purpose and parameters.