Cod Sursa
Cod Sursa
Cod Sursa
root = Tk()
root.title("Music Player")
root.geometry("485x700+290+10")
root.configure(background='#333333')
root.resizable(True, True)
mixer.init()
def SetVolume(val):
mixer.music.set_volume(float(val)/100)
def AddMusic():
path = filedialog.askdirectory()
if path:
os.chdir(path)
songs = os.listdir(path)
def SetVolume(val):
mixer.music.set_volume(float(val)/100)
def PlayMusic():
Music_Name = Playlist.get(ACTIVE)
print(Music_Name[0:-4])
mixer.music.load(Playlist.get(ACTIVE))
mixer.music.set_volume(volume.get()/100) # Set volume
mixer.music.play()
def PauseMusic():
mixer.music.pause()
def StopMusic():
mixer.music.stop()
def PlayNext():
current_index = Playlist.curselection()
if current_index:
next_index = current_index[0] + 1
if next_index < Playlist.size():
Playlist.selection_clear(current_index)
Playlist.activate(next_index)
Playlist.selection_set(next_index)
PlayMusic()
def PlayPrev():
current_index = Playlist.curselection()
if current_index:
prev_index = current_index[0] - 1
if prev_index >= 0:
Playlist.selection_clear(current_index)
Playlist.activate(prev_index)
Playlist.selection_set(prev_index)
PlayMusic()
frameCnt = 30
frames = [PhotoImage(file='D:\\AN 4\\SEM2\AMDM - 4 sem 2\\MP3_Proiect\\menu.gif',
format='gif -index %i' % (i)) for i in range(frameCnt)]
def update(ind):
frame = frames[ind]
ind += 1
if ind == frameCnt:
ind = 0
label.configure(image=frame)
root.after(40, update, ind)
label = Label(root)
label.place(x=0, y=0)
root.after(0, update, 0)
Scroll = Scrollbar(Frame_Music)
Playlist = Listbox(Frame_Music, width=100, font=("Times new roman", 10),
bg="#333333", fg="grey",selectbackground="lightblue", cursor="hand2", bd=0,
yscrollcommand=Scroll.set)
Scroll.config(command=Playlist.yview)
Scroll.pack(side=RIGHT, fill=Y)
Playlist.pack(side=RIGHT, fill=BOTH)
root.mainloop()