πŸ”₯ Advanced MP3 Music Player in Python | CustomTkinter + Pygame | Free Source Code

Demo :


Click Video πŸ‘‡πŸ‘‡πŸ‘‡















Description:

Create a stylish MP3 Music Player in Python using CustomTkinter & Pygame. 🎡 This modern music player allows you to play, pause, resume, and stop MP3 songs from a selected folder. πŸš€ Download full source code and build your own Python music player today!

πŸ”Ή Features:
✅ Load & Play MP3 Songs 🎢
✅ Pause & Resume Music ⏯
✅ Stop Music Anytime ⏹
✅ CustomTkinter Modern UI 🌟
✅ Fully Functional Music Player 🎼


Code :


import pygame

import customtkinter as ctk

from tkinter import filedialog, messagebox


# Initialize Pygame Mixer

pygame.mixer.init()


# Create Main App Window

ctk.set_appearance_mode("dark")  # "light", "dark", "system"

ctk.set_default_color_theme("blue")  # "blue", "green", "dark-blue"


app = ctk.CTk()

app.title("🎡 MP3 Music Player 🎡")

app.geometry("450x500")


# Function to Load MP3 File

def load_song():

    file_path = filedialog.askopenfilename(filetypes=[("MP3 Files", "*.mp3")])

    if file_path:

        pygame.mixer.music.load(file_path)

        song_label.configure(text="Loaded: " + file_path.split("/")[-1])

        messagebox.showinfo("Success", "Song Loaded Successfully!")


# Function to Play Music

def play_music():

    pygame.mixer.music.play()


# Function to Pause Music

def pause_music():

    pygame.mixer.music.pause()


# Function to Resume Music

def resume_music():

    pygame.mixer.music.unpause()


# Function to Stop Music

def stop_music():

    pygame.mixer.music.stop()


# UI Elements

song_label = ctk.CTkLabel(app, text="No Song Loaded", font=("Arial", 16))

song_label.pack(pady=20)


load_button = ctk.CTkButton(app, text="🎡 Load MP3", command=load_song, fg_color="#3b82f6", hover_color="#2563eb")

load_button.pack(pady=5)


play_button = ctk.CTkButton(app, text="▶ Play", command=play_music, fg_color="#16a34a", hover_color="#15803d")

play_button.pack(pady=5)


pause_button = ctk.CTkButton(app, text="⏸ Pause", command=pause_music, fg_color="#f59e0b", hover_color="#d97706")

pause_button.pack(pady=5)


resume_button = ctk.CTkButton(app, text="⏯ Resume", command=resume_music, fg_color="#0ea5e9", hover_color="#0284c7")

resume_button.pack(pady=5)


stop_button = ctk.CTkButton(app, text="⏹ Stop", command=stop_music, fg_color="#ef4444", hover_color="#dc2626")

stop_button.pack(pady=5)


# Run the App

app.mainloop()

Comments

Popular posts from this blog

πŸš€ Simple Login & Registration System in Python Tkinter πŸ“±

πŸš€ Create a Python Screen Recorder with Audio (Complete Code)

Python IP Tracker App with GUI | Track IP Location Real-Time! (Working Project)