def __run_playlist(self): import threading, time # Use a separate thread to reduce the noticeable lag when finding # episodes in a big directory. def generate_playlist(playlist_seed, lock): from aux import find_more_episodes time.sleep(1.5) with lock: self.playlist += find_more_episodes(playlist_seed) playlist_lock = threading.Lock() playlist_thread = threading.Thread(target=generate_playlist, args=(self.playlist[-1],playlist_lock)) playlist_thread.daemon = True playlist_thread.start() # Watchdog thread def watch(m): # wait for media setting up time.sleep(3.0) m.fetch_if_no_local_subtitles() from media import Media while self.playlist: with playlist_lock: f = self.playlist.pop(0) m = Media(f) watch_thread = threading.Thread(target=watch, args=(m,)) watch_thread.daemon = True watch_thread.start() m.play() if singleton.get_mplayer().last_exit_status == 'Quit': break playlist_thread.join()
def __run_playlist(self): import threading, time # Use a separate thread to reduce the noticeable lag when finding # episodes in a big directory. def generate_playlist(playlist_seed, lock): from aux import find_more_episodes time.sleep(1.5) with lock: self.playlist += find_more_episodes(playlist_seed) playlist_lock = threading.Lock() playlist_thread = threading.Thread(target=generate_playlist, args=(self.playlist[-1], playlist_lock)) playlist_thread.daemon = True playlist_thread.start() # Watchdog thread def watch(m): # wait for media setting up time.sleep(3.0) m.fetch_if_no_local_subtitles() from media import Media while self.playlist: with playlist_lock: f = self.playlist.pop(0) m = Media(f) watch_thread = threading.Thread(target=watch, args=(m, )) watch_thread.daemon = True watch_thread.start() m.play() if singleton.get_mplayer().last_exit_status == 'Quit': break playlist_thread.join()
def run(self): if not self.playlist: singleton.get_mplayer().play() else: self.__run_playlist()