In this tutorial, we’ll build PulsePlayer v1.0.2 — a professional desktop music player with:
✅ Spotify-style UI
✅ Playlist management
✅ Album art rotation
✅ Lyrics display
✅ Audio visualizer
✅ Auto resume playback
✅ Persistent playlist saving
By the end, you’ll understand how to structure a real production-style Python desktop application.
🚀 Project Source Code
Clone the full project:
git clone https://github.com/rogers-cyber/PulsePlayer.git
Download Windows executable:
https://github.com/rogers-cyber/PulsePlayer/releases
🧠 What You’ll Learn
- Professional Python app architecture
- VLC media playback in Python
- Tkinter + ttkbootstrap UI design
- Playlist persistence using JSON
- Resume last session feature
- Audio visualization techniques
- Drag & drop file handling
📦 Step 1 — Install Requirements
Install dependencies:
pip install ttkbootstrap python-vlc pillow tinytag numpy tkinterdnd2
Optional:
pip install pyaudio
🏗 Step 2 — Project Structure
Create a Python file:
PulsePlayer.py
We’ll structure the app into:
- Configuration
- Utilities
- Playlist manager
- Player engine
- Visualizer
- GUI
This separation keeps the code professional and maintainable.
⚙️ Step 3 — Configuration
Define app settings and paths.
Why?
Central config makes updates easier and avoids hard-coding values.
APP_NAME = "PulsePlayer"
APP_VERSION = "1.0.2"
SUPPORTED_AUDIO = (".mp3", ".wav", ".flac", ".m4a", ".ogg")
APP_DATA_DIR = Path.home() / ".PulsePlayer"
APP_DATA_DIR.mkdir(exist_ok=True)
PLAYLIST_FILE = APP_DATA_DIR / "playlist.json"
LAST_SESSION_FILE = APP_DATA_DIR / "last_session.json"
What this does
- Stores playlist automatically
- Saves last playback session
- Supports multiple audio formats
🛠 Step 4 — Utility Functions
Create helper functions for audio metadata.
Why?
Keeps reusable logic separate from UI.
class AudioUtils:
@staticmethod
def format_time(sec):
sec = int(sec)
return f"{sec//60:02d}:{sec%60:02d}"
@staticmethod
def is_valid_audio(path):
return path.lower().endswith(SUPPORTED_AUDIO)
You can also extract:
- album art
- lyrics
- metadata
This keeps the GUI clean.
🎵 Step 5 — Playlist Manager (Auto Save + Load)
We store playlists locally using JSON.
Why?
Users don’t want to re-add music every time.
class PlaylistManager:
def __init__(self):
self.playlist = []
self.load_playlist()
def add_files(self, files):
valid = [f for f in files if AudioUtils.is_valid_audio(f)]
self.playlist.extend([f for f in valid if f not in self.playlist])
self.save_playlist()
Save playlist
def save_playlist(self):
with open(PLAYLIST_FILE, "w") as f:
json.dump(self.playlist, f)
Load playlist
def load_playlist(self):
if PLAYLIST_FILE.exists():
with open(PLAYLIST_FILE) as f:
self.playlist = json.load(f)
Now your music library persists automatically.
⚡ Step 6 — Music Player Engine (No GUI)
We separate playback logic from the UI.
Why?
Professional architecture = easier testing + reuse.
class MusicPlayerEngine:
def __init__(self):
self.vlc_instance = vlc.Instance("--no-video")
self.player = self.vlc_instance.media_player_new()
Play track
def load_track(self, path):
media = self.vlc_instance.media_new(path)
self.player.set_media(media)
def play(self):
self.player.play()
This uses VLC for high-performance audio playback.
🎨 Step 7 — Audio Visualizer
We simulate animated audio bars using a canvas.
class AudioVisualizer:
def update(self, root, engine):
if engine.is_playing():
heights = [random.randint(10, 80) for _ in range(50)]
Why this is cool
- Real-time animation
- Smooth UI experience
- Professional feel
🖥 Step 8 — Build the GUI
We use:
- Tkinter → base UI
- ttkbootstrap → modern styling
Create main window
self.root = TkinterDnD.Tk()
self.root.geometry("1200x680")
Playlist UI
self.listbox = tk.Listbox(left)
self.listbox.pack(fill=tk.BOTH, expand=True)
Playback Controls
tb.Button(controls, text="▶", command=self.play_selected)
tb.Button(controls, text="⏸", command=self.pause)
tb.Button(controls, text="⏹", command=self.stop)
💾 Step 9 — Resume Last Session (Pro Feature)
This makes the player behave like Spotify.
Save last track
def save_last_session(self):
data = {
"track": self.engine.filtered_playlist[self.engine.current_index],
"position": self.engine.get_time()
}
Restore on startup
def load_last_session(self):
if LAST_SESSION_FILE.exists():
with open(LAST_SESSION_FILE) as f:
data = json.load(f)
Now playback resumes exactly where users left off.
🧹 Step 10 — Clear Playlist Feature
Allow users to reset their library.
def clear_all_music(self):
self.playlist_manager.playlist.clear()
self.playlist_manager.save_playlist()
▶ Step 11 — Run the Application
if __name__ == "__main__":
app = SpotifyPlayerApp()
app.run()
Run:
python PulsePlayer.py
🎉 Final Result
You now have a professional desktop music player with:
- Persistent playlist
- Resume playback
- Audio visualization
- Album art rotation
- Lyrics support
- Drag & drop music
- Loop and shuffle modes
This architecture is similar to real production desktop apps.
⭐ Full Source Code
Project repository:
git clone https://github.com/rogers-cyber/PulsePlayer.git
Download executable:
https://github.com/rogers-cyber/PulsePlayer/releases
❤️ Conclusion
You learned how to build a real desktop application using:
- Python
- VLC engine
- Tkinter UI
- JSON persistence
- Modular architecture
From here you can extend:
- Crossfade audio
- Streaming support
- Online lyrics API
- Real audio waveform analysis
Happy coding 🚀

Top comments (0)