def _play(self, tag: AVTag) -> None: assert isinstance(tag, SoundOrVideoTag) self._process = subprocess.Popen( self.args + [tag.filename], env=self.env, stdin=subprocess.PIPE, startupinfo=startup_info(), ) self._wait_for_termination(tag)
def _encode_mp3(src_wav: str, dst_mp3: str) -> None: cmd = ["lame", src_wav, dst_mp3, "--noreplaygain", "--quiet"] cmd, env = _packagedCmd(cmd) try: retcode = retryWait(subprocess.Popen(cmd, startupinfo=startup_info(), env=env)) except Exception as e: raise Exception(tr.media_error_running(val=" ").join(cmd)) from e if retcode != 0: raise Exception(tr.media_error_running(val=" ").join(cmd)) os.unlink(src_wav)
def _play(self, tag: AVTag) -> None: assert isinstance(tag, SoundOrVideoTag) filename = hooks.media_file_filter(tag.filename) self._process = subprocess.Popen( self.args + [filename], env=self.env, stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, startupinfo=startup_info(), ) self._wait_for_termination(tag)
def postprocess(self, encode=True) -> None: self.encode = encode for c in processingChain: # print c if not self.encode and c[0] == "lame": continue try: cmd, env = _packagedCmd(c) ret = retryWait( subprocess.Popen(cmd, startupinfo=startup_info(), env=env)) except: ret = True finally: self.cleanup() if ret: raise Exception(_("Error running %s") % " ".join(cmd))
def postprocess(self, encode=True) -> None: self.encode = encode for c in processingChain: # print c if not self.encode and c[0] == "lame": continue try: cmd, env = _packagedCmd(c) ret = retryWait( subprocess.Popen(cmd, startupinfo=startup_info(), env=env)) except: ret = True finally: self.cleanup() if ret: raise Exception(tr(TR.MEDIA_ERROR_RUNNING, val=" ").join(cmd))
else: exeDir = os.path.dirname(os.path.abspath(sys.argv[0])) if isWin and not cmd[0].endswith(".exe"): cmd[0] += ".exe" path = os.path.join(exeDir, cmd[0]) if not os.path.exists(path): return cmd, env cmd[0] = path return cmd, env # Platform hacks ########################################################################## # legacy global for add-ons si = startup_info() # osx throws interrupted system call errors frequently def retryWait(proc: subprocess.Popen) -> int: while 1: try: return proc.wait() except OSError: continue # Simple player implementations ########################################################################## class SimpleProcessPlayer(Player): # pylint: disable=abstract-method