so yeah, i am just making a program which plays music of my favourite game. Now what the thing is that when i call the playsound
function of playsound
(module) then, my programs lags and then eventually crashes. Here is my code:
import tkinter as tk
from playsound import playsound
import multiprocessing
class dynastyMusicer(tk.Tk):
def __init__(self, screenName=None, baseName=None, className='Tk',
useTk=True, sync=False, use=None):
super().__init__(screenName=screenName, baseName=baseName, className=className, useTk=useTk, sync=sync, use=use)
self.title("Dynasty Musicer")
self.geometry("250x100")
self.config(background="white")
chooseL = tk.Label(self, text="Which music to play?", background="white")
chooseL.place(x=50, y=0)
ops = ["Dynasty Dojo", "Dynasty Dojo Fight"]
self.stvar = tk.StringVar(self)
self.stvar.set("Music")
self.option = tk.OptionMenu(self, self.stvar, *ops)
self.option.place(y=30)
btn = tk.Button(self, text="Play", width=10, command=self.play)
btn.place(y=70)
stop = tk.Button(self, text="Stop", width=10, command=self.stop)
stop.place(x=160,y=70)
def stop(self):
multiprocessing.Process(target=playsound, args=(self.stvar.get()+".mp3"))
def play(self):
if self.stvar.get() == "Dynasty Dojo":
playsound(r"path")
elif self.stvar.get() == "Dynasty Dojo Fight":
playsound(r"path")
dm = dynastyMusicer()
dm.mainloop()
also because of this i can't test whether my stop
function is working or not because when you'll click the play button then yeah, you guessed it, it would crash. if you wanna download the two music file i used, here are the links: