Clear playlist if last item in list

This commit is contained in:
angelblue05 2018-01-09 21:03:32 -06:00
parent 900d94a22f
commit e530575d91
3 changed files with 22 additions and 10 deletions

View file

@ -85,6 +85,14 @@ class PlaybackUtils(object):
index = max(self.playlist.getposition(), 0) + 1 # Can return -1 index = max(self.playlist.getposition(), 0) + 1 # Can return -1
force_play = False force_play = False
##### Track end of playlist
playlist_verify = playlist.Playlist().verify_playlist()
try:
if playlist_verify['result']['limits']['end'] >= index:
window('emby.playlist_end', value="true")
except Exception:
pass
# Stack: [(url, listitem), (url, ...), ...] # Stack: [(url, listitem), (url, ...), ...]
self.stack[0][1].setPath(self.stack[0][0]) self.stack[0][1].setPath(self.stack[0][0])
try: try:

View file

@ -413,14 +413,6 @@ class Player(xbmc.Player):
# Will be called when user stops xbmc playing a file # Will be called when user stops xbmc playing a file
log.debug("ONPLAYBACK_STOPPED") log.debug("ONPLAYBACK_STOPPED")
window('emby_customPlaylist.seektime', clear=True) window('emby_customPlaylist.seektime', clear=True)
if self.currentFile in self.played_info:
log.info("Clear playlist.")
if self.played_info[self.currentFile]['Type'] == "Audio":
xbmc.PlayList(xbmc.PLAYLIST_MUSIC).clear()
else:
xbmc.PlayList(xbmc.PLAYLIST_VIDEO).clear()
self.stopAll() self.stopAll()
@log_error() @log_error()
@ -453,6 +445,14 @@ class Player(xbmc.Player):
media_type = data['Type'] media_type = data['Type']
playMethod = data['playmethod'] playMethod = data['playmethod']
if window('emby.playlist_end', value="true"):
window('emby.playlist_end', clear=True)
if media_type == "Audio":
xbmc.PlayList(xbmc.PLAYLIST_MUSIC).clear()
else:
xbmc.PlayList(xbmc.PLAYLIST_VIDEO).clear()
# Prevent manually mark as watched in Kodi monitor # Prevent manually mark as watched in Kodi monitor
window('emby_skipWatched%s' % itemid, value="true") window('emby_skipWatched%s' % itemid, value="true")

View file

@ -144,8 +144,12 @@ class Playlist(object):
log.debug(JSONRPC('Playlist.Insert').execute(params)) log.debug(JSONRPC('Playlist.Insert').execute(params))
@classmethod @classmethod
def verify_playlist(cls): def verify_playlist(cls, playlist_id=1):
log.info(JSONRPC('Playlist.GetItems').execute({'playlistid': 1}))
result = JSONRPC('Playlist.GetItems').execute({'playlistid': playlist_id})
log.info(result)
return result
@classmethod @classmethod
def remove_from_playlist(cls, position): def remove_from_playlist(cls, position):