Skip to content

Commit 29279f7

Browse files
committed
stop currently playing theme before starting to play a new one; resolves stuck volume issues
1 parent cbc5fa0 commit 29279f7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/player.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ def __init__(self, player, rating_key):
632632
util.setGlobalProperty('theme_playing', '1')
633633

634634
self.oldVolume = util.rpc.Application.GetProperties(properties=["volume"])["volume"]
635+
util.DEBUG_LOG("THIS IS OLD VOLUME: %s" % self.oldVolume)
635636

636637
def onPlayBackStarted(self):
637638
util.DEBUG_LOG("BGM: playing theme for %s" % self.currentlyPlaying)
@@ -776,11 +777,18 @@ def play(self, *args, **kwargs):
776777
xbmc.Player.play(self, *args, **kwargs)
777778

778779
def playBackgroundMusic(self, source, volume, rating_key, *args, **kwargs):
779-
if self.isPlaying() and not self.lastPlayWasBGM:
780-
return
780+
if self.isPlaying():
781+
if not self.lastPlayWasBGM:
782+
return
781783

782-
elif self.isPlaying() and self.lastPlayWasBGM and self.handler.currentlyPlaying == rating_key:
783-
return
784+
else:
785+
# don't re-queue the currently playing theme
786+
if self.handler.currentlyPlaying == rating_key:
787+
return
788+
789+
# cancel any currently playing theme before starting the new one
790+
else:
791+
self.stopAndWait()
784792

785793
if self.BGMTask and self.BGMTask.isValid():
786794
self.BGMTask.cancel()

0 commit comments

Comments
 (0)