A simple music player application built with GPUI, Zed's GPU-accelerated UI framework for Rust.
- 🎵 MP3 Playback - Play MP3 audio files using the rodio audio library
▶️ Play/Pause Control - Toggle playback with a single click- ⏩ Seek Forward - Skip forward 10 seconds
- ⏪ Seek Backward - Skip backward 10 seconds
- 📋 Song List - Automatically scans and displays MP3 files in the current directory
- 🎨 Modern UI - Clean, GPU-accelerated interface built with GPUI
- 🔄 Click to Play - Click any song in the list to immediately start playing it
- 🧵 Non-blocking Audio - Audio runs on a dedicated background thread for smooth UI
The application features a centred layout with:
- Application title at the top
- Song list in the middle (with header showing Song name, Song writer, Singer)
- Control panel at the bottom with Seek Backwards, Play/Pause, and Seek Forward buttons
- Rust (2024 Edition)
- macOS (primary development platform)
- MP3 files for playback
| Crate | Version | Purpose |
|---|---|---|
| gpui | 0.2.2 | GPU-accelerated UI framework |
| rodio | 0.21.1 | Audio playback |
| log | 0.4.29 | Logging facade |
| env_logger | 0.11.8 | Logger implementation |
-
Clone the repository:
git clone https://github.com/yourusername/music-player-gpui.git cd music-player-gpui -
Build the project:
cargo build --release
-
Run the application:
cargo run
- Place MP3 files in the same directory as the executable (or the directory where you run the app)
- Launch the application
- The song list will automatically populate with detected MP3 files
- Click on any song in the list to start playback
- Use the play/pause button to toggle playback
- Use the left/right arrow buttons to seek backward/forward by 10 seconds
| Shortcut | Action |
|---|---|
Cmd+Q |
Quit the application |
Ctrl+C |
Quit the application |
music-player-gpui/
├── Cargo.toml # Project dependencies and metadata
├── README.md # This file
├── assets/ # UI assets
│ ├── left-button.png # Seek backward button icon
│ ├── pause-button.png # Pause button icon
│ ├── play-button.png # Play button icon
│ └── right-button.png # Seek forward button icon
└── src/
├── main.rs # Application entry point and main UI
├── audio_manager.rs # Background audio thread management
├── music_list_view.rs # Song list view component
└── play_element.rs # Play/pause button component
The main module sets up the GPUI application window (800x800 pixels) and composes the UI with:
- A title header
- A
ListViewcomponent for displaying songs (usinguniform_listfor efficient rendering) - A control panel with seek backward, play/pause, and seek forward buttons
- Global communication channel for syncing player state between components
Handles audio playback on a dedicated background thread to prevent UI blocking. Features:
- Command-based Architecture: Uses channels (
mpsc) to send commands (Load, Play, Pause, Stop, SeekTo, SeekForward, SeekBackward, Detach, Shutdown) to the audio thread - Position Tracking: Maintains accurate playback position for seeking
- Backward Seek Support: Reloads and seeks when seeking backward (required by most audio decoders)
- Non-blocking Operations: All public methods return immediately
Supported commands:
Load- Load a new audio filePlay/Pause/Stop- Playback controlSeekTo- Seek to specific positionSeekForward/SeekBackward- Relative seeking (10 second steps)Detach- Keep playing until end, then stopShutdown- Clean thread shutdown
A GPUI component that renders the play/pause button and manages the audio state. Features:
- Toggles between play and pause icons based on the current playback state
- Receives player state updates via channel communication
- Provides seek forward/backward functionality (10 second steps)
Scans the current directory for MP3 files and displays them in a virtualized list using GPUI's uniform_list for efficient rendering of large song collections. Features:
- Click any song to load and play it immediately
- Syncs playback state with the play button via channel communication
- Shows a "No songs found" message when the directory is empty
RUST_LOG=info cargo runcargo doc --open- Currently only supports MP3 format
- Song metadata (artist, album) is not yet parsed from files
- Scans only the current working directory for MP3 files
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source. Please add an appropriate license file.