So I want to programm a music player in python 3.7 which can play music and on and scale it shows where I am in the song. I also want that I can fast forward in the song by clicking somewhere on the scale
.
but it gives me the error :
Exception in Tkinter callback Traceback (most recent call last): File "", line 1705, in __call__ return self.func(*args) File "", line 786, in __init__ assert group is None, "group argument must be None for now" AssertionError: group argument must be None for now
it's maybe not clean programmed hope you can see what's wrong or fix it thanks ;)
from pygame import mixer
from tkinter import *
import os
from mutagen.mp3 import MP3
from threading import Thread
import time
r=Tk()
a= 'musicfile.mp3'
filedata = os.path.splitext(a)
audio = MP3(a)
lenghtsound = audio.info.length
mixer.init()
mins, secs = divmod(lenghtsound, 60)
mins = round(mins)
secs = round(secs)
timeformat = '0:{:02d}:{:02d}'.format(mins, secs)
print(timeformat)
def get_sec(time_str):
"""Get Seconds from time."""
h, m, s = time_str.split(':')
return int(h) * 3600 + int(m) * 60 + int(s)
the problem starts here and is something about the " def run(self) " function but i dont know what exactly theres this tiny disc symbol at the border of my code and when i press on it out comes a giant code "threading.py" i guess its an explanation about threeading but i dont understand something there. pls help :(
f = get_sec(timeformat)
x = 0
n = 0
ab = True
class timer(Thread):
def run(self):
global x, f, ab
while ab:
if x == n:
c = n-x
f = f-c
x = n
x = x + 1
de.set(x)
print(x)
if x >= f:
ab = False
mins, secs = divmod(x, 60)
mins = round(mins)
secs = round(secs)
songdurationleft = '{:02d}:{:02d}'.format(mins, secs)
abc2['text']='playing'+songdurationleft
time.sleep(1)
class setppos(Thread):
def run(self):
print('hi')
global n
b = de.get()
mixer.music.set_pos(b)
n = b
def gg():
mixer.music.load(a)
mixer.music.set_volume(0.2)
mixer.music.play()
T1 = timer(daemon=True)
T2 = setppos(daemon=True)
T1.start()
T2.start()
abc = Button(r,command=gg,text='play/start threads')
abc.pack()
abc1 = Label(r,text=timeformat)
abc1.pack(side=LEFT)
abc2 = Label(r,text='song duration:')
abc2.pack(side=RIGHT)
de=Scale(r,from_=0,to_=f,orient=HORIZONTAL,sliderlength=10,length=600,tickinterval=5,showvalue=0,command
=setppos)
de.set(0)
de.pack()
r.mainloop()