Use 1 PKC xbmc.player instance
This commit is contained in:
parent
d6c14d0aa4
commit
eff7d7b68b
5 changed files with 25 additions and 18 deletions
|
@ -21,7 +21,7 @@ class PlexCompanion(threading.Thread):
|
|||
"""
|
||||
Initialize with a Queue for callbacks
|
||||
"""
|
||||
def __init__(self):
|
||||
def __init__(self, player=None):
|
||||
self.logMsg("----===## Starting PlexCompanion ##===----", 1)
|
||||
self.settings = settings.getSettings()
|
||||
|
||||
|
@ -35,6 +35,9 @@ class PlexCompanion(threading.Thread):
|
|||
self.queueId = None
|
||||
self.playlist = None
|
||||
|
||||
# kodi player instance
|
||||
self.player = player
|
||||
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
def _getStartItem(self, string):
|
||||
|
@ -82,11 +85,13 @@ class PlexCompanion(threading.Thread):
|
|||
self.queueId = None
|
||||
if self.playlist is None:
|
||||
if data.get('type') == 'music':
|
||||
self.playlist = playlist.Playlist('music')
|
||||
self.playlist = playlist.Playlist('music',
|
||||
player=self.player)
|
||||
elif data.get('type') == 'video':
|
||||
self.playlist = playlist.Playlist('video')
|
||||
self.playlist = playlist.Playlist('video',
|
||||
player=self.player)
|
||||
else:
|
||||
self.playlist = playlist.Playlist()
|
||||
self.playlist = playlist.Playlist(player=self.player)
|
||||
if queueId != self.queueId:
|
||||
self.logMsg('New playlist received, updating!', 1)
|
||||
self.queueId = queueId
|
||||
|
|
|
@ -20,10 +20,10 @@ from PlexFunctions import scrobble
|
|||
@utils.logging
|
||||
class KodiMonitor(xbmc.Monitor):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, player=None):
|
||||
|
||||
self.doUtils = downloadutils.DownloadUtils().downloadUrl
|
||||
self.xbmcplayer = xbmc.Player()
|
||||
self.xbmcplayer = player
|
||||
xbmc.Monitor.__init__(self)
|
||||
self.logMsg("Kodi monitor started.", 1)
|
||||
|
||||
|
|
|
@ -1549,9 +1549,9 @@ class LibrarySync(Thread):
|
|||
with itemFkt() as Fkt:
|
||||
Fkt.updatePlaystate(item)
|
||||
|
||||
def run(self):
|
||||
def run(self, player=None):
|
||||
try:
|
||||
self.run_internal()
|
||||
self.run_internal(player)
|
||||
except Exception as e:
|
||||
utils.window('plex_dbScan', clear=True)
|
||||
self.logMsg('LibrarySync thread crashed', -1)
|
||||
|
@ -1563,7 +1563,7 @@ class LibrarySync(Thread):
|
|||
self.__language__(39400))
|
||||
raise
|
||||
|
||||
def run_internal(self):
|
||||
def run_internal(self, player=None):
|
||||
# Re-assign handles to have faster calls
|
||||
window = utils.window
|
||||
settings = utils.settings
|
||||
|
@ -1582,7 +1582,7 @@ class LibrarySync(Thread):
|
|||
lastProcessing = 0
|
||||
oneDay = 60*60*24
|
||||
|
||||
xbmcplayer = xbmc.Player()
|
||||
xbmcplayer = player
|
||||
|
||||
queue = self.queue
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class Playlist():
|
|||
"""
|
||||
Initiate with Playlist(typus='video' or 'music')
|
||||
"""
|
||||
def __init__(self, typus=None):
|
||||
def __init__(self, typus=None, player=None):
|
||||
self.userid = utils.window('currUserId')
|
||||
self.server = utils.window('pms_server')
|
||||
# Construct the Kodi playlist instance
|
||||
|
@ -38,7 +38,8 @@ class Playlist():
|
|||
self.typus = None
|
||||
if self.playlist is not None:
|
||||
self.playlistId = self.playlist.getPlayListId()
|
||||
self.player = xbmc.Player()
|
||||
# kodi player instance
|
||||
self.player = player
|
||||
# "interal" PKC playlist
|
||||
self.items = []
|
||||
|
||||
|
|
13
service.py
13
service.py
|
@ -140,7 +140,6 @@ class Service():
|
|||
ws = wsc.WebSocket(queue)
|
||||
library = librarysync.LibrarySync(queue)
|
||||
kplayer = player.Player()
|
||||
xplayer = xbmc.Player()
|
||||
plx = PlexAPI.PlexAPI()
|
||||
|
||||
# Sync and progress report
|
||||
|
@ -167,11 +166,11 @@ class Service():
|
|||
# Verify if user is set and has access to the server
|
||||
if (user.currUser is not None) and user.HasAccess:
|
||||
# If an item is playing
|
||||
if xplayer.isPlaying():
|
||||
if kplayer.isPlaying():
|
||||
try:
|
||||
# Update and report progress
|
||||
playtime = xplayer.getTime()
|
||||
totalTime = xplayer.getTotalTime()
|
||||
playtime = kplayer.getTime()
|
||||
totalTime = kplayer.getTotalTime()
|
||||
currentFile = kplayer.currentFile
|
||||
|
||||
# Update positionticks
|
||||
|
@ -209,7 +208,8 @@ class Service():
|
|||
time=2000,
|
||||
sound=False)
|
||||
# Start monitoring kodi events
|
||||
self.kodimonitor_running = kodimonitor.KodiMonitor()
|
||||
self.kodimonitor_running = kodimonitor.KodiMonitor(
|
||||
player=kplayer)
|
||||
|
||||
# Start the Websocket Client
|
||||
if not self.websocket_running:
|
||||
|
@ -222,7 +222,8 @@ class Service():
|
|||
# Start the Plex Companion thread
|
||||
if not self.plexCompanion_running:
|
||||
self.plexCompanion_running = True
|
||||
plexCompanion = PlexCompanion.PlexCompanion()
|
||||
plexCompanion = PlexCompanion.PlexCompanion(
|
||||
player=kplayer)
|
||||
plexCompanion.start()
|
||||
else:
|
||||
if (user.currUser is None) and self.warn_auth:
|
||||
|
|
Loading…
Reference in a new issue