我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用xbmc.sleep()。
def reset(self, filters=None, silent=False): '''reset skin settings''' log_msg("filters: %s" % filters) if silent or (not silent and xbmcgui.Dialog().yesno(heading=self.addon.getLocalizedString(32010), line1=self.addon.getLocalizedString(32011))): if filters: # only restore specific settings skinsettings = self.get_skinsettings(filters) for setting in skinsettings: xbmc.executebuiltin("Skin.Reset(%s)" % setting[1].encode("utf-8")) else: # restore all skin settings xbmc.executebuiltin("RunScript(script.skinshortcuts,type=resetall&warning=false)") xbmc.sleep(250) xbmc.executebuiltin("Skin.ResetSettings") xbmc.sleep(250) xbmc.executebuiltin("ReloadSkin") # fix default settings and labels xbmc.sleep(1500) xbmc.executebuiltin("RunScript(script.skin.helper.service,action=checkskinsettings)")
def play(self, item='', listitem=None, windowed=False, sublist=None): self._sublist = sublist super(Player, self).play(item, listitem, windowed) self._start_time = time.time() while True: # ???????????5???????????kodi??????? if self._stopped or time.time() - self._start_time > 300: if self._totalTime == 999999: raise PlaybackFailed( 'XBMC silently failed to start playback') break xbmc.sleep(500) # print 'play end'
def get_curplayback(self): '''get current playback details - retry on error''' count = 5 while count and self.active: try: cur_playback = self.dialog.sp.current_playback() return cur_playback except Exception as exc: if "token expired" in str(exc): token = xbmc.getInfoLabel("Window(Home).Property(spotify-token)") self.sp._auth = token else: log_exception(__name__, exc) count -= 1 xbmc.sleep(500) self.dialog.close_dialog() return None
def onPlayBackStarted(self): '''Kodi event fired when playback is started (including next tracks)''' # set the connect_playing bool to indicate we are playing spotify connect content self.__is_paused = False filename = "" while not filename: try: filename = self.getPlayingFile() except: xbmc.sleep(500) if "localhost:%s" % PROXY_PORT in filename: if not self.connect_playing and "connect=true" in filename: # we started playback with (remote) connect player log_msg("Playback started of Spotify Connect stream") self.connect_playing = True if "silence" in filename: self.connect_local = False else: self.connect_local = True if "nexttrack" in filename: # next track requested for kodi player self.__sp.next_track() elif self.connect_playing: self.update_playlist()
def PlayStream(self, url, item, seek, startPlayback=True, package=None): self.currentURL = url if startPlayback: self.play(url, item) if self.service.settings: xbmc.log(self.service.addon.getAddonInfo('name') + ': Playback url ' + str(url), xbmc.LOGNOTICE) if package is not None: self.package = package if seek != '': self.seek = float(seek) if self.service.settings: xbmc.log(self.service.addon.getAddonInfo('name') + ': Seek ' + str(seek), xbmc.LOGNOTICE) # self.tvScheduler.setVideoWatched(self.worksheet, self.content[self.current][0]) # if seek > 0 and seek !='': # while not self.isPlaying(): #<== The should be while self.isPlaying(): # xbmc.sleep(500) # xbmc.sleep(2000) # self.time = float(seek) # self.seekTime(float(seek))
def onInit(self): xbmc.log(msg="[Match Center] Script started", level=xbmc.LOGDEBUG) if os.path.exists(ignored_league_list_file): self.ignored_leagues = [league.lower() for league in eval(FileIO.fileread(ignored_league_list_file)) if league] else: self.ignored_leagues = [] xbmc.executebuiltin("ClearProperty(no-games,Home)") self.getControl(32540).setImage(os.path.join(addon_path,"resources","img","goal.png")) xbmc.executebuiltin("SetProperty(loading-script-matchcenter-livescores,1,home)") self.livescoresThread() xbmc.executebuiltin("ClearProperty(loading-script-matchcenter-livescores,Home)") i = 0 while self.isRunning: if (float(i*200)/(livescores_update_time*60*1000)).is_integer() and ((i*200)/(3*60*1000)) != 0: self.livescoresThread() xbmc.sleep(200) i += 1 xbmc.log(msg="[Match Center] Script stopped", level=xbmc.LOGDEBUG)
def run(): try: xbmc.executebuiltin("ActivateWindow(10147)") window = xbmcgui.Window(10147) xbmc.sleep(100) window.getControl(1).setLabel(translate(32000)) window.getControl(5).setText(translate(32065)) while xbmc.getCondVisibility("Window.IsActive(10147)"): xbmc.sleep(100) ret = xbmcgui.Dialog().yesno(translate(32000), translate(32067)) if ret: xbmc.executebuiltin("RunAddon(script.keymap)") except: traceback.print_stack() xbmc.executebuiltin("XBMC.Notification('"+translate(32000)+"','"+translate(32066)+"','2000','')")
def geoip(self): retry = 0 query = '' while (retry < 6) and (not xbmc.abortRequested): query = self.call('geolookup', 'lang:EN', 'autoip', self.FORMAT) if query != '': retry = 6 else: retry += 1 xbmc.sleep(10000) commons.debug('GeoIP download failed') commons.debug('GeoIP data: %s' % query) data = self._parse(query) if data is not None and data.has_key('location'): location = data['location']['city'] locationid = data['location']['l'][3:] xbmcaddon.Addon().setSetting('Location1', location) xbmcaddon.Addon().setSetting('Location1id', locationid) commons.debug('Detected GeoIP location: %s' % location) else: location = '' locationid = '' return location, locationid
def forecast(self, loc, locid): try: lang = LANG[self.LANG] except: lang = 'EN' opt = 'lang:' + lang commons.debug('Weather location: %s' % locid) retry = 0 query = '' while (retry < 6) and (not xbmc.abortRequested): query = self.call(self.WEATHER_FEATURES, opt, locid, self.FORMAT) if query != '': retry = 6 else: retry += 1 xbmc.sleep(10000) commons.debug('Weather download failed') commons.trace('Forecast data: %s' % query) data = self._parse(query) if data is not None and data.has_key('response') and not data['response'].has_key('error'): self.properties(data, loc, locid) else: self.clear()
def RESTORE(): import time dialog = xbmcgui.Dialog() if zip == '' and ADDON.getSetting('email')=='': dialog.ok('USB BACKUP/RESTORE','You have not set your ZIP Folder.\nPlease update the addon settings and try again.','','') ADDON.openSettings(sys.argv[0]) lib=xbmc.translatePath(os.path.join(zip,'backup.zip')) READ_ZIP(lib) dp.create("USB BACKUP/RESTORE","Checking ",'', 'Please Wait') HOME = xbmc.translatePath(os.path.join('special://','home')) dp.update(0,"", "Extracting Zip Please Wait") extract.all(lib,HOME,dp) time.sleep(1) XfinityInstaller() xbmc.executebuiltin('UpdateLocalAddons ') xbmc.executebuiltin("UpdateAddonRepos") time.sleep(1) xbmc.executebuiltin('UnloadSkin()') xbmc.executebuiltin('ReloadSkin()') Kodi17() dialog.ok("USB BACKUP/RESTORE", "PLEASE REBOOT YOUR BOX IF HOMESCREEN HAS NOT CHANGED", "","") xbmc.executebuiltin("LoadProfile(Master user)")
def showText(heading, text): id = 10147 xbmc.executebuiltin('ActivateWindow(%d)' % id) xbmc.sleep(100) win = xbmcgui.Window(id) retry = 50 while (retry > 0): try: xbmc.sleep(10) retry -= 1 win.getControl(1).setLabel(heading) win.getControl(5).setText(text) return except: pass
def resolve(self, url, proxy=None, maxbitrate=0, player=None): self.stopPlaying=threading.Event() progress = xbmcgui.DialogProgress() progress.create('Starting local proxy') progress.update(20, "", 'Loading local proxy', "") self.stopPlaying.clear() t = threading.Thread(target=self.__start, args=(self.stopPlaying, player,)) t.daemon = True t.start() url_to_play = self.__prepare_url(url, proxy, maxbitrate=maxbitrate) xbmc.sleep(100) progress.update(100, "", "", "") progress.close() return url_to_play, player.MAIN_MIME_TYPE
def onPlayBackStarted(self): for i in range(0, 200): if control.condVisibility('Window.IsActive(busydialog)') == 1: control.idle() else: break control.sleep(100) if control.setting('playback_info') == 'true': elapsedTime = '%s %s %s' % (control.lang(30464).encode('utf-8'), int((time.time() - self.loadingTime)), control.lang(30465).encode('utf-8')) control.infoDialog(elapsedTime, heading=self.name) try: if self.offset == '0': raise Exception() self.seekTime(float(self.offset)) except: pass try: if not control.setting('subtitles') == 'true': raise Exception() control.log('XXXXXXX Subs:%s' % self.name) try: subtitle = subtitles.get(self.name, self.imdb, self.season, self.episode) except: subtitle = subtitles.get(self.name, self.imdb, '', '') except: pass
def handle_wait(time_to_wait, title, text): logger.info("handle_wait(time_to_wait=%d)" % time_to_wait) espera = dialog_progress(' ' + title, "") secs = 0 increment = int(100 / time_to_wait) cancelled = False while secs < time_to_wait: secs += 1 percent = increment * secs secs_left = str((time_to_wait - secs)) remaining_display = ' Espera ' + secs_left + ' segundos para que comience el vídeo...' espera.update(percent, ' ' + text, remaining_display) xbmc.sleep(1000) if espera.iscanceled(): cancelled = True break if cancelled: logger.info('Espera cancelada') return False else: logger.info('Espera finalizada') return True
def waitforDB(database): if database == 'tv': import tv c = tv.tvDB.cursor() tbl = 'shows' else: import movies c = movies.MovieDB.cursor() tbl = 'movies' error = True while error: error = False try: c.execute('select distinct * from ' + tbl).fetchone() except Exception: error = True xbmc.sleep(1000) Log('Database locked') c.close()
def run(self): # threading.Thread.run(self) #log(' p-running ' + str( self.work_list )) self.running = True # Rather than running forever, check to see if it is still OK while self.running: try: # Don't block #item = self.queue.get(block=False) self.do_work() self.ev.set() #work dome end log( ' p-all done ' ) self.stop() except Empty: # Allow other stuff to run time.sleep(0.1)
def wait(self): # wait in chunks of 500ms to react earlier on exit request chunk_wait_time = int(CHUNK_WAIT_TIME) remaining_wait_time = int(self.NEXT_IMAGE_TIME) while remaining_wait_time > 0: if self.exit_requested: self.log('wait aborted') return if self.toggle_info_display_requested: #this value is set on specific keypress in action_id_handler #self.log('toggle_info_display_requested') self.toggle_info_display_requested=False self.toggle_info_display_handler() if remaining_wait_time < chunk_wait_time: chunk_wait_time = remaining_wait_time remaining_wait_time -= chunk_wait_time xbmc.sleep(chunk_wait_time)
def populate_subreddits_pickle(): from guis import progressBG loading_indicator=progressBG(translation(32023)) #Gathering icons.. with open(subredditsFile, 'r') as fh: subreddit_settings = fh.readlines() #xbmc_notify("initializing", "Building icons cache", 5000) loading_indicator.set_tick_total(len(subreddit_settings)) for entry in subreddit_settings: entry=entry.strip() loading_indicator.tick(1,entry) s=convert_settings_entry_into_subreddits_list_or_domain(entry) if s: #t = threading.Thread(target=get_subreddit_entry_info_thread, args=(s,) ) log('processing saved entry:'+repr(entry)) get_subreddit_entry_info_thread(s) xbmc.sleep(2000) loading_indicator.end()
def _set_resolved_url(self, context, base_item, succeeded=True): item = xbmc_items.to_item(context, base_item) item.setPath(base_item.get_uri()) xbmcplugin.setResolvedUrl(self.handle, succeeded=succeeded, listitem=item) """ # just to be sure :) if not isLiveStream: tries = 100 while tries>0: xbmc.sleep(50) if xbmc.Player().isPlaying() and xbmc.getCondVisibility("Player.Paused"): xbmc.Player().pause() break tries-=1 """
def onPlayBackStarted( self ): # only do something if we're playing audio if self.isPlayingAudio(): # we need to keep track of this bool for stopped/ended notifications self.Audio = True # keep track of onPlayBackStarted events http://trac.xbmc.org/ticket/13064 self.Count += 1 log('#DEBUG# onPlayBackStarted: %i' % self.Count) # tags are not available instantly and we don't what to announce right away as the user might be skipping through the songs xbmc.sleep(2000) # don't announce if user already skipped to the next track if self.Count == 1: # reset counter self.Count = 0 # get tags tags = self._get_tags() # announce song self.action(tags, self.service) else: # multiple onPlayBackStarted events occurred, only act on the last one log('#DEBUG# skipping onPlayBackStarted event') self.Count -= 1
def onFocus(self, controlID): if controlID == self.MAIN_BUTTON_ID: self.selectedOffset = self.trueOffset() if self.lastFocusID == self.BIG_SEEK_LIST_ID: xbmc.sleep(100) self.updateBigSeek() else: self.setBigSeekShift() self.updateProgress() elif controlID == self.BIG_SEEK_LIST_ID: self.setBigSeekShift() self.updateBigSeek() elif xbmc.getCondVisibility('ControlGroup(400).HasFocus(0)'): self.selectedOffset = self.trueOffset() self.updateProgress() self.lastFocusID = controlID
def playQueueCallback(self, **kwargs): mli = self.playlistListControl.getSelectedItem() pi = mli.dataSource plexID = pi['comment'].split(':', 1)[0] viewPos = self.playlistListControl.getViewPosition() self.fillPlaylist() for ni in self.playlistListControl: if ni.dataSource['comment'].split(':', 1)[0] == plexID: self.playlistListControl.selectItem(ni.pos()) break xbmc.sleep(100) newViewPos = self.playlistListControl.getViewPosition() if viewPos != newViewPos: diff = newViewPos - viewPos self.playlistListControl.shiftView(diff, True)
def playQueueCallback(self, **kwargs): self.setProperty('pq.isshuffled', player.PLAYER.handler.playQueue.isShuffled and '1' or '') mli = self.playlistListControl.getSelectedItem() pi = mli.dataSource plexID = pi['comment'].split(':', 1)[0] viewPos = self.playlistListControl.getViewPosition() self.fillPlaylist() for ni in self.playlistListControl: if ni.dataSource['comment'].split(':', 1)[0] == plexID: self.playlistListControl.selectItem(ni.pos()) break xbmc.sleep(100) newViewPos = self.playlistListControl.getViewPosition() if viewPos != newViewPos: diff = newViewPos - viewPos self.playlistListControl.shiftView(diff, True)
def setSubtitles(self): subs = self.player.video.selectedSubtitleStream() if subs: xbmc.sleep(100) self.player.showSubtitles(False) path = subs.getSubtitleServerPath() if path: if self.mode == self.MODE_ABSOLUTE: util.DEBUG_LOG('Setting subtitle path: {0}'.format(path)) self.player.setSubtitles(path) self.player.showSubtitles(True) else: util.DEBUG_LOG('Transcoded. Skipping subtitle path: {0}'.format(path)) else: # util.TEST(subs.__dict__) # util.TEST(self.player.video.mediaChoice.__dict__) if self.mode == self.MODE_ABSOLUTE: util.DEBUG_LOG('Enabling embedded subtitles at: {0}'.format(subs.typeIndex)) util.DEBUG_LOG('Kodi reported subtitles: {0}'.format(self.player.getAvailableSubtitleStreams())) self.player.setSubtitleStream(subs.typeIndex) self.player.showSubtitles(True) else: self.player.showSubtitles(False)
def _set_resolved_url(self, context, base_item, succeeded=True): item = xbmc_items.to_item(context, base_item) item.setPath(base_item.get_uri()) xbmcplugin.setResolvedUrl(context.get_handle(), succeeded=succeeded, listitem=item) """ # just to be sure :) if not isLiveStream: tries = 100 while tries>0: xbmc.sleep(50) if xbmc.Player().isPlaying() and xbmc.getCondVisibility("Player.Paused"): xbmc.Player().pause() break tries-=1 """
def start(thread=True): if thread: t = threading.Thread(target=start, args=[False]) t.setDaemon(True) t.start() else: import time update_wait = [0, 10000, 20000, 30000, 60000] wait = update_wait[int(config.get_setting("update_wait", "videolibrary"))] if wait > 0: time.sleep(wait) if not config.get_setting("update", "videolibrary") == 2: check_for_update(overwrite=False) # Se ejecuta ciclicamente while True: monitor_update() time.sleep(3600) # cada hora
def onAction(self, action): if (action == ACTION_SELECT_ITEM or action == 100) and self.getFocusId() == 6: selectitem = self.getControl(6).getSelectedItem() id_actor = selectitem.getProperty("id_actor") name_info = selectitem.getProperty("name_info") thumbnail = selectitem.getProperty("thumbnail") job = selectitem.getProperty("job") dialog = platformtools.dialog_progress("Cargando nuevos datos", "Obteniendo datos del %s..." % job.lower()) global ActorInfoWindow ActorInfoWindow = ActorInfo(id=id_actor, name=name_info, thumbnail=thumbnail, item=self.item, fonts=self.fonts, dialog=dialog, job=job) ActorInfoWindow.doModal() xbmc.sleep(400) elif (action == ACTION_SELECT_ITEM or action == 100) and self.getFocusId() == 5: self.close() elif action == ACTION_PREVIOUS_MENU or action == ACTION_GESTURE_SWIPE_LEFT or action == 110 or action == 92: self.close()
def fixKeymaps(): # Fix the keymap file name if it's been changed or the old name was being used name = getKeyMapsFileName() old = getOldKeyMapsFileName() dir = getKeyMapsPath("*") full_name = getKeyMapsPath(name) try: debugTrace("Getting contents of keymaps directory " + dir) files = (glob.glob(dir)) if not full_name in files and len(files) > 0: for file in files: if (name in file) or (old in file): infoTrace("common.py", "Renaming " + file + " to " + full_name) xbmcvfs.rename(file, full_name) xbmc.sleep(100) # Wait 10 seconds for rename to happen otherwise quit and let it fail in the future for i in range(0, 9): if xbmcvfs.exists(full_name): break xbmc.sleep(1000) return True except Exception as e: errorTrace("common.py", "Problem fixing the keymap filename.") errorTrace("common.py", str(e)) return False
def getCycleLock(): # If the lock is forced, don't wait, just return (ie don't queue) if xbmcgui.Window(10000).getProperty("VPN_Manager_Cycle_Lock") == "Forced Locked" : return False # If there's already a queue on the lock, don't wait, just return if not xbmcgui.Window(10000).getProperty("VPN_Manager_Cycle_Lock_Queued") == "" : return False # Loop until we get the lock or time out after 5 seconds xbmcgui.Window(10000).setProperty("VPN_Manager_Cycle_Lock_Queued", "Queued") i = 0 while i < 5 and not xbmcgui.Window(10000).getProperty("VPN_Manager_Cycle_Lock") == "": xbmc.sleep(1000) i = i + 1 # Free the queue so another call can wait on it xbmcgui.Window(10000).setProperty("VPN_Manager_Cycle_Lock_Queued", "") # Return false if a forced lock happened whilst we were queuing if xbmcgui.Window(10000).getProperty("VPN_Manager_Cycle_Lock") == "Forced Locked" : return False # Return false if the lock wasn't obtained because of a time out if i == 5 : return False xbmcgui.Window(10000).setProperty("VPN_Manager_Cycle_Lock", "Locked") return True
def writeCredentials(addon): # Write the credentials file try: credentials_path = getCredentialsPath(addon) debugTrace("Writing VPN credentials file to " + credentials_path) credentials = open(credentials_path,'w') credentials.truncate() credentials.close() credentials = open(credentials_path,'a') credentials.write(addon.getSetting("vpn_username")+"\n") credentials.write(addon.getSetting("vpn_password")+"\n") credentials.close() except Exception as e: errorTrace("common.py", "Couldn't create credentials file " + credentials_path) errorTrace("common.py", str(e)) return False xbmc.sleep(500) return True
def get(version): try: import xbmc,xbmcgui,xbmcaddon,xbmcvfs f = xbmcvfs.File(xbmcaddon.Addon().getAddonInfo('changelog')) text = f.read() ; f.close() label = '%s - %s' % (xbmc.getLocalizedString(24054), xbmcaddon.Addon().getAddonInfo('name')) id = 10147 xbmc.executebuiltin('ActivateWindow(%d)' % id) xbmc.sleep(100) win = xbmcgui.Window(id) retry = 50 while (retry > 0): try: xbmc.sleep(10) win.getControl(1).setLabel(label) win.getControl(5).setText(text) retry = 0 except: retry -= 1 return '1' except: return '1'
def run(self, title, year, season, episode, imdb, tvdb, url, meta): try: control.sleep(200) self.totalTime = 0 ; self.currentTime = 0 self.content = 'movie' if season == None or episode == None else 'episode' self.title = title ; self.year = year self.name = urllib.quote_plus(title) + urllib.quote_plus(' (%s)' % year) if self.content == 'movie' else urllib.quote_plus(title) + urllib.quote_plus(' S%02dE%02d' % (int(season), int(episode))) self.name = urllib.unquote_plus(self.name) self.season = '%01d' % int(season) if self.content == 'episode' else None self.episode = '%01d' % int(episode) if self.content == 'episode' else None self.DBID = None self.imdb = imdb if not imdb == None else '0' self.tvdb = tvdb if not tvdb == None else '0' self.ids = {'imdb': self.imdb, 'tvdb': self.tvdb} self.ids = dict((k,v) for k, v in self.ids.iteritems() if not v == '0') self.offset = bookmarks().get(self.name, self.year) poster, thumb, meta = self.getMeta(meta) item = control.item(path=url) item.setArt({'icon': thumb, 'thumb': thumb, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster}) item.setInfo(type='Video', infoLabels = meta) if 'plugin' in control.infoLabel('Container.PluginName'): control.player.play(url, item) control.resolve(int(sys.argv[1]), True, item) control.window.setProperty('script.trakt.ids', json.dumps(self.ids)) self.keepPlaybackAlive() control.window.clearProperty('script.trakt.ids') except: return
def idleForPlayback(self): for i in range(0, 200): if control.condVisibility('Window.IsActive(busydialog)') == 1: control.idle() else: break control.sleep(100)
def show_message(message, title=xbmcaddon.Addon().getLocalizedString(50107)): if not message: return xbmc.executebuiltin("ActivateWindow(%d)" % (10147, )) win = xbmcgui.Window(10147) xbmc.sleep(100) win.getControl(1).setLabel(title) win.getControl(5).setText(message)
def showMessage(message, title = lang(50001)): if not message: return xbmc.executebuiltin("ActivateWindow(%d)" % 10147) win = xbmcgui.Window(10147) xbmc.sleep(100) win.getControl(1).setLabel(title) win.getControl(5).setText(message)
def create_temp(): '''create temp folder for skin backup/restore''' temp_path = u'%stemp/' % ADDON_DATA # workaround weird slashes behaviour on some platforms. temp_path = temp_path.replace("//","/").replace("special:/","special://") if xbmcvfs.exists(temp_path): recursive_delete_dir(temp_path) xbmc.sleep(2000) xbmcvfs.mkdirs(temp_path) xbmcvfs.mkdirs(temp_path + "skinbackup/") return temp_path
def restore_guisettings(self, filename, progressdialog): '''restore guisettings''' kodifile = xbmcvfs.File(filename, 'r') data = kodifile.read() importstring = eval(data) kodifile.close() xbmc.sleep(200) for count, skinsetting in enumerate(importstring): if progressdialog and progressdialog.iscanceled(): return setting = skinsetting[1] settingvalue = skinsetting[2] if progressdialog: progressdialog.update((count * 100) / len(importstring), '%s %s' % (self.addon.getLocalizedString(32033), setting)) if skinsetting[0] == "string": if settingvalue: xbmc.executebuiltin("Skin.SetString(%s,%s)" % (setting, settingvalue)) else: xbmc.executebuiltin("Skin.Reset(%s)" % setting) elif skinsetting[0] == "bool": if settingvalue == "true": xbmc.executebuiltin("Skin.SetBool(%s)" % setting) else: xbmc.executebuiltin("Skin.Reset(%s)" % setting) xbmc.sleep(30)
def copy_file(source, destination, do_wait=False): '''copy a file on the filesystem, wait for the action to be completed''' if xbmcvfs.exists(destination): delete_file(destination) xbmcvfs.copy(source, destination) if do_wait: count = 20 while count: xbmc.sleep(500) # this first sleep is intentional if xbmcvfs.exists(destination): break count -= 1
def delete_file(filepath, do_wait=False): '''delete a file on the filesystem, wait for the action to be completed''' xbmcvfs.delete(filepath) if do_wait: count = 20 while count: xbmc.sleep(500) # this first sleep is intentional if not xbmcvfs.exists(filepath): break count -= 1
def fill_fake_buffer(self): '''emulate playback by just slowly reading the stdout''' # We could pick up this data in a buffer but it is almost impossible to keep it all in sync. # So instead we ignore the audio from the connect daemon completely and we # just launch a standalone instance to play the track while not self.__exit: line = self.__spotty_proc.stdout.readline() xbmc.sleep(1)
def next_track(self): '''special entry which tells the remote connect player to move to the next track''' # move to next track self.sp.next_track() # play next track xbmc.sleep(100) cur_playback = self.sp.current_playback() trackdetails = cur_playback["item"] url, li = parse_spotify_track(trackdetails, silenced=True) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
def _fill_buffer(self): while self._running: self._buffer_lock.acquire() if len(self._buffer) <= self.MIN_BUFFER_SIZE: log_msg("Spotify radio track buffer was %d, below minimum size of %d - filling" % (len(self._buffer), self.MIN_BUFFER_SIZE), xbmc.LOGDEBUG) self._buffer += self._fetch() self._buffer_lock.release() else: self._buffer_lock.release() time.sleep(self.CHECK_BUFFER_PERIOD)
def playList(self, service): while self.current < len(self.mediaItems) and not self.isExit: self.playNext(service, self.mediaItems[self.current]) current = self.current while current == self.current and not self.isExit: xbmc.sleep(3000) if self.service.settings: xbmc.log(self.service.addon.getAddonInfo('name') + ': Exit play list', xbmc.LOGNOTICE) # def onPlayBackSeek(self,offset):
def seekTo(self, seek): if seek != '': self.seek = float(seek) # self.tvScheduler.setVideoWatched(self.worksheet, self.content[self.current][0]) if seek > 0 and seek !='': while not self.isPlaying(): #<== The should be while self.isPlaying(): xbmc.sleep(500) xbmc.sleep(2000) self.time = float(seek) self.seekTime(float(seek)) if self.service.settings: xbmc.log(self.service.addon.getAddonInfo('name') + ': Seek ' + str(self.time), xbmc.LOGNOTICE)
def get_base_datas(): """ Fetch the header nav datas from API and clean it (menu items) """ global main_data if main_data is None: site = 'media' # 'data-site' attr from body url = common.rtbf_url + 'news/api/menu?site=%s' % site progressdialog = xbmcgui.DialogProgress() progressdialog.create(common.plugin.addon.getAddonInfo('name')) progressdialog.update(0, 'Récupération des données...') common.plugin.log("get_base_datas") try: json_data = utils.request_url(url) if not json_data: return main_data = json.loads(json_data) #will generate unicode main_data = clean_base_datas(main_data) progressdialog.update(100, 'Done!') except: main_data = False progressdialog.update(0, 'Échec!') xbmc.sleep(1000) progressdialog.close() #common.plugin.log("before clean_base_datas:") #common.plugin.log(json.dumps(main_data)) #common.plugin.log("after clean_base_datas:") #common.plugin.log(json.dumps(main_data)) return main_data
def onInit(self): xbmc.log(msg="[Match Center] Twitter cycle started", level=xbmc.LOGDEBUG) self.getControl(32540).setImage(os.path.join(addon_path,"resources","img","goal.png")) xbmc.executebuiltin("SetProperty(loading-script-matchcenter-twitter,1,home)") self.getTweets() xbmc.executebuiltin("ClearProperty(loading-script-matchcenter-twitter,Home)") i=0 while self.isRunning: if (float(i*200)/(twitter_update_time*60*1000)).is_integer() and ((i*200)/(3*60*1000)) != 0: self.getTweets() xbmc.sleep(200) i += 1 xbmc.log(msg="[Match Center] Twitter cycle stopped", level=xbmc.LOGDEBUG)