Pyglet, player, next song Pyglet, player, next song tkinter tkinter

Pyglet, player, next song


Try making the following change to your next_song()

def next_song():    player.next_source()

Reason
Refer this page
https://pyglet.readthedocs.org/en/pyglet-1.2-maintenance/api/pyglet/media/pyglet.media.Player.html#pyglet.media.Player.time

You will find that next() is "Deprecated" and is recommend to use next_source() rather

HTH

PS When I tested you snippet on my machine it worked.


YOU can use os module ,or just see the process of playing next song ,i thought it may help for many people, who may using os module or anyother, to play next song use global variable ,its important

from tkinter import *import osroot = Tk()root.geometry("500x500")root.title("music player ")Label(root, text="MUSIC PLAYER").pack()i=0def prev():   passdef paly():    music_dir = 'D:\songs'    songs = os.listdir(music_dir)    print(songs)    os.startfile(os.path.join(music_dir, songs[0]))def nxt():    global i    music_dir = 'D:\songs'    songs = os.listdir(music_dir)    print(songs)    os.startfile(os.path.join(music_dir, songs[i]))    i=i+1f1=Frame(root).pack()Button(f1,text="prev",command=prev).pack(side=LEFT,padx=30)Button(f1,text="play/pause",command=paly).pack(side=LEFT,padx=30)Button(f1,text="next",command=nxt).pack(side=LEFT,padx=30)root.mainloop()