Информация о загрузке

master
Бородин Роман 2019-05-05 11:46:05 +03:00
parent 47946616e7
commit de00e999b0
1 changed files with 15 additions and 6 deletions

View File

@ -4,17 +4,17 @@ from .utils import get_engine, localize
class TorrentPlayer(xbmc.Player) :
pyrrent_engine = None
loop = None
paused = False
def onPlayBackEnded(self):
self.pyrrent_engine.close()
self.loop.stopped = True
xbmc.Player().stop()
def onPlayBackPaused(self):
self.pyrrent_engine.pause()
#self.loop.overlay.show()
self.paused = True
def onPlayBackResumed(self):
self.loop.overlay.hide()
#self.pyrrent_engine.resume()
self.paused = False
self.pyrrent_engine.resume()
def onPlayBackStopped(self):
self.pyrrent_engine.close()
@ -47,7 +47,7 @@ class TorrentPlayer(xbmc.Player) :
pw.close()
break
fstat = self.pyrrent_engine.file_status(f_index)
listitem = xbmcgui.ListItem('.'.join(fstat.name.split('.')[:-1]), path=fstat.url)
listitem = xbmcgui.ListItem('.'.join(fstat.name.split('/')[-1].split('.')[:-1])[:-1], path=fstat.url)
xbmc.Player.play(self, fstat.url, listitem)
class VideoLoop(object):
@ -55,13 +55,22 @@ class VideoLoop(object):
def __init__(self, torr_fp):
self.e = get_engine(torr_fp)
def start(self, f_index):
self.statinfo = xbmcgui.Dialog()
self.mediaPlayer = TorrentPlayer()
self.mediaPlayer.loop = self
self.mediaPlayer.play(self.e, f_index)
while not self.stopped:
# sometime busydialog is showing in infinite loop. kick it.
if xbmc.getCondVisibility('Window.IsVisible(busydialog)'):
xbmc.executebuiltin("Dialog.Close(busydialog)")
xbmc.executebuiltin("Dialog.Close(busydialog)")
status = self.e.status()
f_status = self.e.file_status(f_index)
if self.mediaPlayer.paused:
self.statinfo.notification('[{}]{}.'.format(('|' * (int(f_status.progress * 100) / 2)).ljust(50, '.'), ' ' * 100),
'S: {} DL: {} KB/s UL: {} KB/s'.format(status.num_seeds,
status.download_rate,
status.upload_rate),
time=2, sound=False
)
xbmc.sleep(1000)