mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-13 21:56:11 +00:00
Adjust playback progress monitor
Only track progress report if the item is an emby item
This commit is contained in:
parent
085e243e86
commit
702ce0beac
2 changed files with 31 additions and 28 deletions
|
@ -92,6 +92,7 @@ class Service(xbmc.Monitor):
|
||||||
Threads depending on abortRequest will not trigger.
|
Threads depending on abortRequest will not trigger.
|
||||||
'''
|
'''
|
||||||
self.monitor = monitor.Monitor()
|
self.monitor = monitor.Monitor()
|
||||||
|
player = self.monitor.player
|
||||||
self.connect = connect.Connect()
|
self.connect = connect.Connect()
|
||||||
self.start_default()
|
self.start_default()
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ class Service(xbmc.Monitor):
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if self.monitor.player.isPlaying():
|
if player.isPlaying() and player.is_playing_file(player.get_playing_file()):
|
||||||
difference = datetime.today() - self.settings['last_progress']
|
difference = datetime.today() - self.settings['last_progress']
|
||||||
|
|
||||||
if difference.seconds > 10:
|
if difference.seconds > 10:
|
||||||
|
|
|
@ -10,7 +10,7 @@ import xbmc
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
||||||
from objects.obj import Objects
|
from objects.obj import Objects
|
||||||
from helper import _, api, window, settings, dialog, event, JSONRPC
|
from helper import _, api, window, settings, dialog, event, silent_catch, JSONRPC
|
||||||
from emby import Emby
|
from emby import Emby
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
@ -32,6 +32,17 @@ class Player(xbmc.Player):
|
||||||
self.__dict__ = self._shared_state
|
self.__dict__ = self._shared_state
|
||||||
xbmc.Player.__init__(self)
|
xbmc.Player.__init__(self)
|
||||||
|
|
||||||
|
@silent_catch()
|
||||||
|
def get_playing_file(self):
|
||||||
|
return self.getPlayingFile()
|
||||||
|
|
||||||
|
@silent_catch()
|
||||||
|
def get_file_info(self, file):
|
||||||
|
return self.played[file]
|
||||||
|
|
||||||
|
def is_playing_file(self, file):
|
||||||
|
return file in self.played
|
||||||
|
|
||||||
def onPlayBackStarted(self):
|
def onPlayBackStarted(self):
|
||||||
|
|
||||||
''' We may need to wait for info to be set in kodi monitor.
|
''' We may need to wait for info to be set in kodi monitor.
|
||||||
|
@ -150,11 +161,11 @@ class Player(xbmc.Player):
|
||||||
''' Only for after playback started
|
''' Only for after playback started
|
||||||
'''
|
'''
|
||||||
LOG.info("Setting audio: %s subs: %s", audio, subtitle)
|
LOG.info("Setting audio: %s subs: %s", audio, subtitle)
|
||||||
current_file = self.getPlayingFile()
|
current_file = self.get_playing_file()
|
||||||
|
|
||||||
if current_file in self.played:
|
if self.is_playing_file(current_file):
|
||||||
|
|
||||||
item = self.played[current_file]
|
item = self.get_file_info(current_file)
|
||||||
mapping = item['SubsMapping']
|
mapping = item['SubsMapping']
|
||||||
|
|
||||||
if audio and len(self.getAvailableAudioStreams()) > 1:
|
if audio and len(self.getAvailableAudioStreams()) > 1:
|
||||||
|
@ -224,8 +235,7 @@ class Player(xbmc.Player):
|
||||||
|
|
||||||
def next_up(self):
|
def next_up(self):
|
||||||
|
|
||||||
current_file = self.getPlayingFile()
|
item = self.get_file_info(self.get_playing_file())
|
||||||
item = self.played[current_file]
|
|
||||||
objects = Objects()
|
objects = Objects()
|
||||||
|
|
||||||
if item['Type'] != 'Episode' or not item.get('CurrentEpisode'):
|
if item['Type'] != 'Episode' or not item.get('CurrentEpisode'):
|
||||||
|
@ -266,20 +276,20 @@ class Player(xbmc.Player):
|
||||||
event("upnext_data", next_info, hexlify=True)
|
event("upnext_data", next_info, hexlify=True)
|
||||||
|
|
||||||
def onPlayBackPaused(self):
|
def onPlayBackPaused(self):
|
||||||
current_file = self.getPlayingFile()
|
current_file = self.get_playing_file()
|
||||||
|
|
||||||
if current_file in self.played:
|
if self.is_playing_file(current_file):
|
||||||
|
|
||||||
self.played[current_file]['Paused'] = True
|
self.get_file_info(current_file)['Paused'] = True
|
||||||
self.report_playback()
|
self.report_playback()
|
||||||
LOG.debug("-->[ paused ]")
|
LOG.debug("-->[ paused ]")
|
||||||
|
|
||||||
def onPlayBackResumed(self):
|
def onPlayBackResumed(self):
|
||||||
current_file = self.getPlayingFile()
|
current_file = self.get_playing_file()
|
||||||
|
|
||||||
if current_file in self.played:
|
if self.is_playing_file(current_file):
|
||||||
|
|
||||||
self.played[current_file]['Paused'] = False
|
self.get_file_info(current_file)['Paused'] = False
|
||||||
self.report_playback()
|
self.report_playback()
|
||||||
LOG.debug("--<[ paused ]")
|
LOG.debug("--<[ paused ]")
|
||||||
|
|
||||||
|
@ -287,12 +297,7 @@ class Player(xbmc.Player):
|
||||||
|
|
||||||
''' Does not seem to work in Leia??
|
''' Does not seem to work in Leia??
|
||||||
'''
|
'''
|
||||||
try:
|
if self.is_playing_file(self.get_playing_file()):
|
||||||
current_file = self.getPlayingFile()
|
|
||||||
except Exception:
|
|
||||||
return
|
|
||||||
|
|
||||||
if current_file in self.played:
|
|
||||||
|
|
||||||
self.report_playback()
|
self.report_playback()
|
||||||
LOG.info("--[ seek ]")
|
LOG.info("--[ seek ]")
|
||||||
|
@ -302,17 +307,12 @@ class Player(xbmc.Player):
|
||||||
''' Report playback progress to emby server.
|
''' Report playback progress to emby server.
|
||||||
Check if the user seek.
|
Check if the user seek.
|
||||||
'''
|
'''
|
||||||
try:
|
current_file = self.get_playing_file()
|
||||||
current_file = self.getPlayingFile()
|
|
||||||
|
|
||||||
if current_file not in self.played:
|
|
||||||
return
|
|
||||||
except Exception as error:
|
|
||||||
LOG.error(error)
|
|
||||||
|
|
||||||
|
if not self.is_playing_file(current_file):
|
||||||
return
|
return
|
||||||
|
|
||||||
item = self.played[current_file]
|
item = self.get_file_info(current_file)
|
||||||
|
|
||||||
if window('emby.external.bool'):
|
if window('emby.external.bool'):
|
||||||
return
|
return
|
||||||
|
@ -388,7 +388,7 @@ class Player(xbmc.Player):
|
||||||
LOG.info("Played info: %s", self.played)
|
LOG.info("Played info: %s", self.played)
|
||||||
|
|
||||||
for file in self.played:
|
for file in self.played:
|
||||||
item = self.played[file]
|
item = self.get_file_info(file)
|
||||||
|
|
||||||
if item:
|
if item:
|
||||||
window('emby.skip.%s.bool' % item['Id'], True)
|
window('emby.skip.%s.bool' % item['Id'], True)
|
||||||
|
@ -408,6 +408,8 @@ class Player(xbmc.Player):
|
||||||
item['Server']['api'].session_stop(data)
|
item['Server']['api'].session_stop(data)
|
||||||
|
|
||||||
if item.get('LiveStreamId'):
|
if item.get('LiveStreamId'):
|
||||||
|
|
||||||
|
LOG.info("<[ livestream/%s ]", item['LiveStreamId'])
|
||||||
item['Server']['api'].close_live_stream(item['LiveStreamId'])
|
item['Server']['api'].close_live_stream(item['LiveStreamId'])
|
||||||
|
|
||||||
elif item['PlayMethod'] == 'Transcode':
|
elif item['PlayMethod'] == 'Transcode':
|
||||||
|
|
Loading…
Reference in a new issue