From b60e62a56d51b537dcd2926bee027aaa321daf2b Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Thu, 23 Sep 2021 16:57:10 -0500 Subject: [PATCH] Fixed function to get the next song automatically --- src/controller/player.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/controller/player.py b/src/controller/player.py index 59726b5..d1b9dae 100644 --- a/src/controller/player.py +++ b/src/controller/player.py @@ -53,6 +53,8 @@ class audioPlayer(object): if item.download_url == "": item.get_download_url() log.debug("playing {0}...".format(item.download_url,)) + if hasattr(self, "player") and self.player != None and self.player.is_playing: + self.player.stop() self.player = stream.URLStream(item.download_url) if self.player.play() == -1: log.debug("Error when playing the file {0}".format(item.title,)) @@ -122,15 +124,11 @@ class audioPlayer(object): """ Check if the stream has reached the end of the file so it will play the next song. """ if self.player != None and self.player.is_playing == False and self.stopped == False and len(self.player) == self.player.position: if self.queue_pos >= len(self.queue): - self.stopped = True - self.playing_all = False - return - elif self.playing_all == False: self.stopped = True return elif self.queue_pos < len(self.queue): self.queue_pos += 1 - self.play(self.queue[self.playing_track]) + self.play(self.queue[self.queue_pos]) def playback_error(self, event): pub.sendMessage("notify", title=_("Error"), message=_("There was an error while trying to access the file you have requested."))