Coders Packet

Offline Music Player using Tkinter Python

By Kaushik karthikeyan K

This Project is to develop a Music Player which works offline using the Tkinter module in Python.

Introduction:

          This Project is to develop a Music Player which works offline using the Tkinter module in Python. By Choosing the Music Folder, It can play all songs for you.

 

Advantages:

1.Easy to use

2.No Extra Memory Needed

3.Simple and User Friendly

 

Requirements: 

Python Any Versions

Tkinter Module:

Os Module:

Pygame Module:

 

Coding:

import pygame
import tkinter as tkr
from tkinter.filedialog import askdirectory
import os

musicplayer = tkr.Tk() musicplayer.title("Offline Music Player") musicplayer.geometry("450x350") directory = askdirectory() os.chdir(directory) songlist = os.listdir() playlist = tkr.Listbox(musicplayer, font ="Helvetica 12 bold", bg="yellow",selectmode= tkr.SINGLE) for item in songlist: pos = 0 playlist.insert(pos, item) pos = pos + 1 pygame.init() pygame.mixer.init() def play(): pygame.mixer.music.load(playlist.get(tkr.ACTIVE)) var.set(playlist.get(tkr.ACTIVE)) pygame.mixer.music.play() def ExitMusicPlayer(): pygame.mixer.music.stop() def pause(): pygame.mixer.music.pause() def unpause(): pygame.mixer.music.unpause() Button1 = tkr.Button(musicplayer,width=5,height=3, font="Helvetica 12 bold",text="PLAY",command=play,bg="black",fg="gold") Button2 = tkr.Button(musicplayer,width=5,height=3, font="Helvetica 12 bold",text="STOP",command=ExitMusicPlayer,bg="black",fg="silver") Button3 = tkr.Button(musicplayer,width=5,height=3, font="Helvetica 12 bold",text="PAUSE",command=pause,bg="black",fg="blue") Button4 = tkr.Button(musicplayer,width=5,height=3, font="Helvetica 12 bold",text="CONTINUE",command=unpause,bg="black",fg="gold") var = tkr.StringVar() songtitle = tkr.Label(musicplayer, font="Helvetica 12 bold", textvariable=var) songtitle.pack() Button1.pack(fill="x") Button2.pack(fill="x") Button3.pack(fill="x") Button4.pack(fill="x") playlist.pack(fill="both",expand="yes") musicplayer.mainloop()

 

Output:

output

 

Conclusion:

 From the Above project, we learned some modules in Tkinter and pygame and used them to create a Music player.

Download project

Reviews Report

Submitted by Kaushik karthikeyan K (kousikrish)

Download packets of source code on Coders Packet