Make a Working Music Player using Python|MP3 player GUI|Music player using tkinter|Pydroid3|Part 3


Note:-
You have to paste the path of image files in the code else it will display error messages.
To know where you have to paste the path of image files please watch tutorial which is present below the source code.
This is just a small part of the MUSIC PLAYER code.You will get the full code in our blog or you can also find it on our Youtube channel.

CODE:-

from tkinter import *
import tkinter as tk
from tkinter import filedialog


root=tk.Tk()
root.geometry("1020x2180")
root.title("Music Player")
root.config(bg='white')

frame1=tk.Frame(root,bg='white')
frame1.pack()

frame2=tk.Frame(root,bg='white')
frame2.pack()

frame3=tk.Frame(root,bg='white')
frame3.pack()

frame4=tk.Frame(root,bg='white')
frame4.pack(pady=30)


#Function to Add songs
def add_songs():
    songs=filedialog.askopenfiles(initialdir='/storage/emulated/0/')
    
#TOPBAR 
Top_btn=Button(frame1,text="Add Songs",relief="raised",borderwidth=5,width=50,command=add_songs)
Top_btn.pack(expand=YES,fill=X,padx=20,pady=20)

#Timebar
time_label=Label(frame3,text="0:00")
time_label.pack(padx=20,pady=20)
#Center Image

Centerimage=PhotoImage(file='/storage/emulated/0/pixelLab/20211111_134042.png')

#Center image placement

Centerimgbutton=Label(frame2,image=Centerimage,borderwidth=2,bg='white')
Centerimgbutton.grid(padx=50,pady=250)

#BUTTON IMAGES
img_play_btn=PhotoImage(file='/storage/emulated/0/pixelLab/20211111_131217.png')
img_stop_btn=PhotoImage(file='/storage/emulated/0/pixelLab/20211111_195345.png')
img_fwd_btn=PhotoImage(file='/storage/emulated/0/pixelLab/20211111_130319.png')
img_back_btn=PhotoImage(file='/storage/emulated/0/pixelLab/20211111_130655.png')
img_shuffle_btn=PhotoImage(file='/storage/emulated/0/pixelLab/20211111_131516.png')
img_loop_btn=PhotoImage(file='/storage/emulated/0/pixelLab/20211111_131551.png')

#FUNCTION FOR CHANGING THE BUTTON

def change_pic(variable):
        if variable == 1:
            play_btn.configure(image=img_stop_btn)
            play_btn.configure(command=lambda variable = 0:change_pic(variable))
            root.update()
       
        elif variable ==0:
             play_btn.configure(image=img_play_btn)
             play_btn.configure(command=lambda variable = 1:change_pic(variable))
             root.update()
         
    
#BUTTONS

shuffle_btn=Button(frame4,image=img_shuffle_btn,bg='white')
play_btn=Button(frame4,bg='white',image=img_play_btn,borderwidth=0,command=lambda variable=1 :change_pic(1))
stop_btn=Button(frame4,image=img_stop_btn,borderwidth=0,command=lambda variable=0 :change_pic(0))
fwd_btn=Button(frame4,bg='white',image=img_fwd_btn,borderwidth=0)
back_btn=Button(frame4,bg='white',image=img_back_btn,borderwidth=0)
loop_btn=Button(frame4,bg='white',image=img_loop_btn,borderwidth=0)


shuffle_btn.pack(side=LEFT,padx=70,pady=10)
back_btn.pack(side=LEFT,padx=5,pady=10)
play_btn.pack(side=LEFT,padx=5,pady=10)
fwd_btn.pack(side=LEFT,padx=5,pady=10)
loop_btn.pack(side=LEFT,padx=70,pady=10)

    


root.mainloop()
#Code ended

Youtube tutorial


"Hope it helped"
Have anything in mind? Let me 
know in the comment section👇


Next Post Previous Post
No Comment
Add Comment
comment url