Skip to content

Commit

Permalink
stop currently playing theme before starting to play a new one; resol…
Browse files Browse the repository at this point in the history
…ves stuck volume issues
  • Loading branch information
pannal committed Jan 19, 2019
1 parent cbc5fa0 commit 29279f7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ def __init__(self, player, rating_key):
util.setGlobalProperty('theme_playing', '1')

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

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

def playBackgroundMusic(self, source, volume, rating_key, *args, **kwargs):
if self.isPlaying() and not self.lastPlayWasBGM:
return
if self.isPlaying():
if not self.lastPlayWasBGM:
return

elif self.isPlaying() and self.lastPlayWasBGM and self.handler.currentlyPlaying == rating_key:
return
else:
# don't re-queue the currently playing theme
if self.handler.currentlyPlaying == rating_key:
return

# cancel any currently playing theme before starting the new one
else:
self.stopAndWait()

if self.BGMTask and self.BGMTask.isValid():
self.BGMTask.cancel()
Expand Down

0 comments on commit 29279f7

Please sign in to comment.