From bb3a2370ef79d99014710f83798c517cb49d4694 Mon Sep 17 00:00:00 2001 From: Sebastian S Date: Sat, 19 Jan 2019 09:33:03 +0100 Subject: [PATCH] Clear playlist on player.onstop --- resources/lib/monitor.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/resources/lib/monitor.py b/resources/lib/monitor.py index 014fe6d0..ab031086 100644 --- a/resources/lib/monitor.py +++ b/resources/lib/monitor.py @@ -79,6 +79,18 @@ class Monitor(xbmc.Monitor): data = json.loads(binascii.unhexlify(data[0])) else: if method not in ('Player.OnPlay', 'VideoLibrary.OnUpdate', 'Player.OnAVChange'): + + ''' We have to clear the playlist if it was stopped before it has been played completely. + Otherwise the next played item will be added the previous queue. + ''' + if method == "Player.OnStop": + xbmc.sleep(2000) # let's wait for the player so we don't clear the canceled playlist by mistake. + + if xbmc.getCondVisibility("!Player.HasMedia"): + + xbmc.executebuiltin("Playlist.Clear") + LOG.info("[ playlist ] cleared") + return data = json.loads(data)