def waitForPlayBackStopped(self,title):
time.sleep(0.5)
self._showOsd()
self.osdActive = False
time.sleep(int(ADDON.getSetting('playback.osd.timeout')))
countdown = int(ADDON.getSetting('playback.timeout'))
while countdown:
time.sleep(1)
countdown = countdown - 1
if self.player.isPlaying():
if self.mode == MODE_OSD and not self.osdActive:
self._hideOsd()
return
if self.tryingToPlay == False:
return
dialog = xbmcgui.Dialog()
dialog.notification('Stream Failed', title, xbmcgui.NOTIFICATION_ERROR, 5000, sound=True)
finish = False
if ADDON.getSetting('play.alt.continue') == 'true':
if self.alt_urls:
url = self.alt_urls.pop(0)
#dialog.notification('Trying', url, xbmcgui.NOTIFICATION_ERROR, 5000, sound=True)
#TODO meta
if url.startswith('@'):
if self.vpnswitch: self.api.filterAndSwitch(url[1:], 0, self.vpndefault, True)
xbmc.executebuiltin('XBMC.RunPlugin(%s)' % url[1:])
elif url[0:14] == "ActivateWindow":
xbmc.executebuiltin(url)
elif url[0:9] == 'plugin://':
if self.vpnswitch: self.api.filterAndSwitch(url, 0, self.vpndefault, True)
if self.alternativePlayback:
xbmc.executebuiltin('XBMC.RunPlugin(%s)' % url)
else:
self.player.play(item=url, windowed=self.osdEnabled)
else:
if self.vpndefault: self.api.defaultVPN(True)
if ADDON.getSetting('m3u.read') == 'true':
if url.startswith('http') and url.split('?')[0].split('.')[-1].startswith('m3u'):
m3u = xbmcvfs.File(url,'rb').read()
match = re.findall('EXT-X-STREAM-INF.*?BANDWIDTH=(.*?),.*?\n(http.*?)\n',m3u,re.M)
streams = [[m[0],m[1]] for m in sorted(match, key=lambda x: int(x[0]), reverse=True)]
if streams:
url = streams[0][1]
self.player.play(item=url, windowed=self.osdEnabled)
self.tryingToPlay = True
if ADDON.getSetting('play.minimized') == 'false':
self._hideEpg()
self._hideQuickEpg()
threading.Timer(1, self.waitForPlayBackStopped, [title]).start()
else:
finish = True
else:
finish = True
if finish:
if not self.osdActive:
self._hideOsd()
self.onRedrawEPG(self.channelIdx, self.viewStartDate)
评论列表
文章目录