Unsolved Playing music in background
-
Hello.
I want to play music in list in background and have a control on stop theme. when i play the music my Qt form doesn't response to other function. Should i implement QThread How ?for i in listChecked: self.playsoundQu(i)
and the function :
def playsoundQu(self,filename): filename = "Downloads/"+filename vlc_instance = vlc.Instance() media = vlc_instance.media_new(filename) player = vlc_instance.media_player_new() player.set_media(media) player.play() time.sleep(1.5) duration = player.get_length() / 1000 time.sleep(duration)
It works but form doen't response to other action and is somehow locked.
-
@behruz-montazeri
I don't know much about python, but my guess is, that "time.sleep" is causing the "freeze" of your Gui, as it will do in pure c++ -
@behruz-montazeri Make player a member variable, so it does not disappear when playsoundQu finishes and then remove all the sleep() calls from playsoundQu...