From: James Bunton Date: Sat, 18 Jan 2014 07:08:12 +0000 (+1100) Subject: Switch to VLC X-Git-Url: https://code.delx.au/bluplayer/commitdiff_plain/082b32b6d419aeedd1a02508cf9f4d6e45e51621 Switch to VLC --- diff --git a/bluplayer.py b/bluplayer.py index 9c76010..1328ade 100755 --- a/bluplayer.py +++ b/bluplayer.py @@ -35,8 +35,9 @@ def find_path(binary): return value set_env_config("MAKEMKVCON_PATH", find_path("makemkvcon")) -set_env_config("MPLAYER_PATH", find_path("mplayer")) -set_env_config("MPLAYER_OPTS", None) +set_env_config("PLAYER_NAME", "vlc") +set_env_config("PLAYER_PATH", find_path(PLAYER_NAME)) +set_env_config("PLAYER_OPTS", None) def grab_xml(url): @@ -135,39 +136,36 @@ class MakeMkvCon(object): self.buf += data -class MPlayer(QObject): +class Player(QObject): play_finished = pyqtSignal() fatal_error = pyqtSignal(str, str) def run(self): - logging.info("mplayer thread started") + logging.info("player thread started") - if not os.path.isfile(MPLAYER_PATH): + if not os.path.isfile(PLAYER_PATH): self.fatal_error.emit( - "MPlayer was not found.", - "Please install MPlayer. If you already have done so you " + - "may set the MPLAYER_PATH environment variable to the " + - "absolute path to the mplayer executable." + PLAYER_NAME + " was not found.", + "Please install it. If you already have done so you " + + "may set the PLAYER_PATH environment variable to the " + + "absolute path to the player executable." ) return - if MPLAYER_OPTS: - self.opts = MPLAYER_OPTS.split() + if PLAYER_OPTS: + self.opts = PLAYER_OPTS.split() else: self.opts = [ - "-fs", - "-nocache", - "-lavdopts", "threads=%s" % get_num_cpus(), - "-volume", "100", + "--fullscreen", ] def play(self, video_url): video_url = str(video_url) - logging.info("Running mplayer: %s", video_url) + logging.info("Running player: %s", video_url) try: - subprocess.check_call([MPLAYER_PATH] + self.opts + [video_url]) + subprocess.check_call([PLAYER_PATH] + self.opts + [video_url]) except Exception, e: - self.fatal_error.emit("MPlayer failed to play the video.", fmt_exc(e)) + self.fatal_error.emit("Failed to play the video.", fmt_exc(e)) finally: self.play_finished.emit() @@ -387,10 +385,10 @@ def main(): makemkv.moveToThread(makemkv_thread) makemkv_thread.started.connect(makemkv.run) - mplayer = MPlayer() - mplayer_thread = QThread() - mplayer.moveToThread(mplayer_thread) - mplayer_thread.started.connect(mplayer.run) + player = Player() + player_thread = QThread() + player.moveToThread(player_thread) + player_thread.started.connect(player.run) makemkv.title_loaded.connect(player_window.add_title) makemkv.title_load_complete.connect(player_window.select_longest_title) @@ -398,9 +396,9 @@ def main(): makemkv.fatal_error.connect(error_dialog.fatal_error) makemkv.title_load_complete.connect(loading_dialog.reset) - player_window.video_selected.connect(mplayer.play) - mplayer.play_finished.connect(player_window.set_play_finished) - mplayer.fatal_error.connect(error_dialog.fatal_error) + player_window.video_selected.connect(player.play) + player.play_finished.connect(player_window.set_play_finished) + player.fatal_error.connect(error_dialog.fatal_error) player_window.fatal_error.connect(error_dialog.fatal_error) error_dialog.fatal_error.connect(loading_dialog.reset) @@ -408,17 +406,17 @@ def main(): logging.info("Starting application") makemkv_thread.start() - mplayer_thread.start() + player_thread.start() result = app.exec_() logging.info("Shutting down") makemkv_thread.quit() - mplayer_thread.quit() + player_thread.quit() killall_makemkvcon() logging.info("Waiting for makemkv thread") makemkv_thread.wait(2000) - logging.info("Waiting for mplayer thread") - mplayer_thread.wait(2000) + logging.info("Waiting for player thread") + player_thread.wait(2000) logging.info("Exiting...") sys.exit(result)