Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽต Music Player

๐Ÿ› ๏ธ Skills & Technologies


๐ŸŽง Overview

A lightweight desktop music player application built with Python, featuring a graphical user interface created with Tkinter and audio playback powered by Pygame Mixer.

The application scans a specified local directory for .mp3 files and displays them in a playlist, allowing users to select and control their music directly from the GUI.


โœจ Features

  • ๐ŸŽต Load local .mp3 audio files.
  • ๐Ÿ“‚ Automatically scan a configured music directory.
  • ๐Ÿ“‹ Display available songs in a playlist.
  • โ–ถ๏ธ Play selected songs.
  • โธ๏ธ Pause and resume playback.
  • โน๏ธ Stop the current song.
  • โฎ๏ธ Navigate to the previous song.
  • โญ๏ธ Navigate to the next song.
  • ๐ŸŽจ Dark-themed desktop interface.
  • ๐Ÿ–ผ๏ธ Custom button icons.
  • ๐Ÿ”Š Audio playback using Pygame Mixer.

๐Ÿ–ฅ๏ธ Interface

The application provides a simple desktop music-player interface consisting of:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Music Player                โ”‚
โ”‚                                              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ song_01.mp3                            โ”‚  โ”‚
โ”‚  โ”‚ song_02.mp3                            โ”‚  โ”‚
โ”‚  โ”‚ song_03.mp3                            โ”‚  โ”‚
โ”‚  โ”‚ song_04.mp3                            โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                              โ”‚
โ”‚              Currently Playing               โ”‚
โ”‚                                              โ”‚
โ”‚       โฎ    โน    โ–ถ    โธ    โญ               โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐ŸŽฎ Controls

Button Function
โฎ๏ธ Previous Plays the previous song in the playlist
โน๏ธ Stop Stops playback and clears the selection
โ–ถ๏ธ Play Plays the selected song
โธ๏ธ Pause Pauses or resumes the current song
โญ๏ธ Next Plays the next song in the playlist

โš™๏ธ How It Works

The application uses several Python modules to handle the GUI, filesystem operations, file filtering, and audio playback.

1. GUI Initialization

Tkinter creates the main application window:

canvas = tk.Tk()
canvas.title("Music player")
canvas.geometry("600x800")
canvas.config(bg="black")

2. Audio Initialization

Pygame Mixer handles audio playback:

from pygame import mixer

mixer.init()

3. Finding Music Files

The application searches the configured directory for .mp3 files:

pattern = "*.mp3"

for root, dirs, files in os.walk(rootpath):
    for filename in fnmatch.filter(files, pattern):
        listBox.insert("end", filename)

4. Playing a Song

When a song is selected, its filename is retrieved from the playlist and loaded into the mixer:

mixer.music.load(rootpath + "\\" + listBox.get("anchor"))
mixer.music.play()

5. Playlist Navigation

The application allows navigation through the songs using the selected playlist index.

Current Song
     โ”‚
     โ”œโ”€โ”€ Previous โ†’ Song - 1
     โ”‚
     โ””โ”€โ”€ Next     โ†’ Song + 1

6. Pause / Resume

The application uses Pygame Mixer to pause and resume the current track:

mixer.music.pause()
mixer.music.unpause()

๐Ÿงฐ Technologies Used

Python

The main programming language used to develop the application.

Tkinter

Used to create the graphical user interface, including:

  • Main window
  • Playlist
  • Buttons
  • Labels
  • Frames

Pygame Mixer

Used for:

  • Loading audio files
  • Playing music
  • Pausing playback
  • Resuming playback
  • Stopping playback

OS

Used to navigate through the music directory and discover audio files.

fnmatch

Used to filter files based on the .mp3 pattern.


๐Ÿ“ Project Structure

Music-Player/
โ”‚
โ”œโ”€โ”€ MusicPlayer.py
โ”œโ”€โ”€ prev_img.png
โ”œโ”€โ”€ stop_img.png
โ”œโ”€โ”€ play_img.png
โ”œโ”€โ”€ pause_img.png
โ”œโ”€โ”€ next_img.png
โ””โ”€โ”€ README.md

The button image files are required by the application because they are loaded directly using tk.PhotoImage.


๐Ÿ“ฆ Installation

1. Clone the Repository

git clone https://github.com/MostafaNabil21/MusicPlayer.git
cd MusicPlayer

2. Install Pygame

Tkinter is included with most standard Python installations. Install Pygame with:

pip install pygame

๐ŸŽต Configure Your Music Directory

Set the rootpath variable in the Python file to the directory containing your MP3 files:

rootpath = "C:\\Users\\YourName\\Music"

For example:

rootpath = "D:\\Music"

The application searches this directory and adds matching .mp3 files to the playlist.


โ–ถ๏ธ Run the Application

Run the Python file:

python MusicPlayer.py

The Music Player window will open and display the available MP3 files.

Select a song from the playlist and use the playback controls to control the music.


๐Ÿงฉ Main Functions

Function Purpose
select() Loads and plays the selected song
stop() Stops the current song
play_next() Plays the next song
play_prev() Plays the previous song
pause_song() Pauses or resumes playback

๐Ÿ’ก Project Concepts

This project demonstrates practical Python programming concepts including:

  • Object-oriented GUI framework usage
  • Event-driven programming
  • Function-based application design
  • File-system traversal
  • File pattern matching
  • GUI widgets
  • Button callbacks
  • Playlist management
  • Audio playback
  • External Python libraries
  • Local file handling

๐Ÿš€ Future Improvements

Possible improvements for future versions include:

  • ๐Ÿ”€ Shuffle mode
  • ๐Ÿ” Repeat mode
  • ๐Ÿ”Š Volume control
  • โฑ๏ธ Song progress bar
  • โญ๏ธ Automatic next-song playback
  • ๐Ÿ“‚ Browse/select music folder from the GUI
  • ๐ŸŽผ Support for additional audio formats
  • ๐Ÿ–ผ๏ธ Album artwork
  • ๐ŸŽš๏ธ Audio volume slider
  • ๐Ÿ“ Editable playlists
  • ๐Ÿ” Song search
  • ๐Ÿ’พ Save playlists between sessions

๐Ÿ“š Project Learning Outcomes

Through this project, I practiced building a complete desktop application with Python by combining:

Python
   โ†“
Tkinter GUI
   โ†“
File System Handling
   โ†“
Playlist Management
   โ†“
Pygame Audio Engine
   โ†“
Interactive Music Player

The project demonstrates how Python can be used to build interactive desktop applications that combine graphical interfaces with real-time audio functionality.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages