Move xbmc.Player()

This commit is contained in:
croneter 2018-11-23 08:41:05 +01:00
parent 1b11c55d84
commit 3e41f63c62
8 changed files with 12 additions and 12 deletions

View file

@ -34,6 +34,8 @@ class App(object):
self.websocket_queue = Queue.Queue() self.websocket_queue = Queue.Queue()
# xbmc.Monitor() instance from kodimonitor.py # xbmc.Monitor() instance from kodimonitor.py
self.monitor = None self.monitor = None
# xbmc.Player() instance
self.player = None
def load_settings(self): def load_settings(self):
# Number of items to fetch and display in widgets # Number of items to fetch and display in widgets

View file

@ -29,7 +29,6 @@ class KodiMonitor(xbmc.Monitor):
PKC implementation of the Kodi Monitor class. Invoke only once. PKC implementation of the Kodi Monitor class. Invoke only once.
""" """
def __init__(self): def __init__(self):
self.xbmcplayer = xbmc.Player()
self._already_slept = False self._already_slept = False
self.hack_replay = None self.hack_replay = None
xbmc.Monitor.__init__(self) xbmc.Monitor.__init__(self)

View file

@ -504,7 +504,7 @@ def process_indirect(key, offset, resolve=True):
result.listitem = listitem result.listitem = listitem
pickler.pickle_me(result) pickler.pickle_me(result)
else: else:
thread = Thread(target=app.APP.monitor.xmbcplayer.play, thread = Thread(target=app.APP.player.play,
args={'item': utils.try_encode(playurl), args={'item': utils.try_encode(playurl),
'listitem': listitem}) 'listitem': listitem})
thread.setDaemon(True) thread.setDaemon(True)
@ -546,10 +546,10 @@ def threaded_playback(kodi_playlist, startpos, offset):
""" """
Seek immediately after kicking off playback is not reliable. Seek immediately after kicking off playback is not reliable.
""" """
app.APP.monitor.xmbcplayer.play(kodi_playlist, None, False, startpos) app.APP.player.play(kodi_playlist, None, False, startpos)
if offset and offset != '0': if offset and offset != '0':
i = 0 i = 0
while not app.APP.monitor.xmbcplayer.isPlaying(): while not app.APP.player.isPlaying():
app.APP.monitor.waitForAbort(0.1) app.APP.monitor.waitForAbort(0.1)
i += 1 i += 1
if i > 100: if i > 100:

View file

@ -87,7 +87,7 @@ def init_playqueue_from_plex_children(plex_id, transient_token=None):
PL.add_item_to_playlist(playqueue, i, plex_id=api.plex_id()) PL.add_item_to_playlist(playqueue, i, plex_id=api.plex_id())
playqueue.plex_transient_token = transient_token playqueue.plex_transient_token = transient_token
LOG.debug('Firing up Kodi player') LOG.debug('Firing up Kodi player')
app.APP.xbmcplayer.play(playqueue.kodi_pl, None, False, 0) app.APP.player.play(playqueue.kodi_pl, None, False, 0)
return playqueue return playqueue

View file

@ -175,14 +175,14 @@ class PlexCompanion(backgroundthread.KillableThread):
if 'audioStreamID' in data: if 'audioStreamID' in data:
index = playqueue.items[pos].kodi_stream_index( index = playqueue.items[pos].kodi_stream_index(
data['audioStreamID'], 'audio') data['audioStreamID'], 'audio')
app.APP.monitor.xbmcplayer.setAudioStream(index) app.APP.player.setAudioStream(index)
elif 'subtitleStreamID' in data: elif 'subtitleStreamID' in data:
if data['subtitleStreamID'] == '0': if data['subtitleStreamID'] == '0':
app.APP.monitor.xbmcplayer.showSubtitles(False) app.APP.player.showSubtitles(False)
else: else:
index = playqueue.items[pos].kodi_stream_index( index = playqueue.items[pos].kodi_stream_index(
data['subtitleStreamID'], 'subtitle') data['subtitleStreamID'], 'subtitle')
app.APP.monitor.xbmcplayer.setSubtitleStream(index) app.APP.player.setSubtitleStream(index)
else: else:
LOG.error('Unknown setStreams command: %s', data) LOG.error('Unknown setStreams command: %s', data)
@ -267,7 +267,7 @@ class PlexCompanion(backgroundthread.KillableThread):
# Start up instances # Start up instances
request_mgr = httppersist.RequestMgr() request_mgr = httppersist.RequestMgr()
subscription_manager = subscribers.SubscriptionMgr(request_mgr, subscription_manager = subscribers.SubscriptionMgr(request_mgr,
app.APP.monitor.xbmcplayer) app.APP.player)
self.subscription_manager = subscription_manager self.subscription_manager = subscription_manager
if utils.settings('plexCompanion') == 'true': if utils.settings('plexCompanion') == 'true':

View file

@ -134,7 +134,7 @@ class MyHandler(BaseHTTPRequestHandler):
CLIENT_DICT[self.client_address[0]] = [] CLIENT_DICT[self.client_address[0]] = []
tracker = CLIENT_DICT[self.client_address[0]] tracker = CLIENT_DICT[self.client_address[0]]
tracker.append(self.client_address[1]) tracker.append(self.client_address[1])
while (not app.APP.monitor.xbmcplayer.isPlaying() and while (not app.APP.player.isPlaying() and
not app.APP.monitor.abortRequested() and not app.APP.monitor.abortRequested() and
sub_mgr.stop_sent_to_web and not sub_mgr.stop_sent_to_web and not
(len(tracker) >= 4 and (len(tracker) >= 4 and

View file

@ -124,8 +124,6 @@ class SubscriptionMgr(object):
self.lastplayers = {} self.lastplayers = {}
# In order to signal a stop to Plex Web ONCE on playback stop # In order to signal a stop to Plex Web ONCE on playback stop
self.stop_sent_to_web = True self.stop_sent_to_web = True
self.xbmcplayer = player
self.request_mgr = request_mgr self.request_mgr = request_mgr
def _server_by_host(self, host): def _server_by_host(self, host):

View file

@ -238,6 +238,7 @@ class Service():
app.init() app.init()
# Some plumbing # Some plumbing
app.APP.monitor = kodimonitor.KodiMonitor() app.APP.monitor = kodimonitor.KodiMonitor()
app.APP.player = xbmc.Player()
artwork.IMAGE_CACHING_SUSPENDS = [ artwork.IMAGE_CACHING_SUSPENDS = [
app.SYNC.suspend_library_thread, app.SYNC.suspend_library_thread,
app.SYNC.stop_sync, app.SYNC.stop_sync,