public void run() {
    Throwable tr = null;
    try {
      List<Object> cmdArray = ((List<Object>) (new ArrayList<Object>(20)));
      cmdArray.add(((Object) (SettingsAdapter.getInstance().getMPlayerCommand())));
      if (MPlayer.isChangingProcessPrioritySupported()) {
        cmdArray.add("-priority");
        cmdArray.add(((Object) (SettingsAdapter.getInstance().getMPlayerProcessPriority().name())));
      }
      cmdArray.add("-ss");
      cmdArray.add(((Object) (Long.toString(mOffset))));
      cmdArray.add(((Object) (player.mFile.getPath())));
      if (logger.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        String s;
        for (Iterator<Object> iterator = cmdArray.iterator();
            iterator.hasNext();
            sb.append(s).append(' ')) s = (String) iterator.next();

        logger.debug(
            ((Object)
                ((new StringBuilder("Executing ["))
                    .append(((Object) (sb)))
                    .append("]")
                    .toString())));
      }
      mProc =
          Runtime.getRuntime()
              .exec((String[]) cmdArray.toArray(((Object[]) (new String[cmdArray.size()]))));
      logger.debug(
          ((Object) ((new StringBuilder("  as process ")).append(((Object) (mProc))).toString())));
      threadStartupDone = true;
      StreamGobbler errorGobbler = new StreamGobbler("stderr", mProc.getErrorStream());
      errorGobbler.start();
      StreamGobbler outputGobbler = new StreamGobbler("stdout", mProc.getInputStream());
      outputGobbler.start();
      int exitCode = mProc.waitFor();
      logger.debug(
          ((Object)
              ((new StringBuilder())
                  .append(((Object) (mProc)))
                  .append(" finished with exit code ")
                  .append(exitCode)
                  .toString())));
    } catch (Exception e) {
      logger.error("", ((Throwable) (e)));
      tr = ((Throwable) (e));
    } finally {
      threadStartupDone = true;
      terminated = true;
    }
    if (tr != null) player.fireExceptionEvent(tr);
  }
Beispiel #2
0
  static int exec(String line, boolean showOutput, File dir) throws Exception {
    Process process = null;

    if (showOutput) {
      System.out.println("exec: " + line);
    }

    process = Runtime.getRuntime().exec("cmd /c " + line, null, dir);
    InputStream stdin = process.getInputStream();
    InputStream stderr = process.getErrorStream();

    StreamGobbler stdinGobbler = new StreamGobbler(stdin, "stdin: ");
    StreamGobbler stderrGobbler = new StreamGobbler(stderr, "stderr: ");
    stdinGobbler.start();
    stderrGobbler.start();
    process.waitFor();
    if (showOutput) {
      System.out.println("exec \"" + line + "\" returned " + process.exitValue());
    }
    return process.exitValue();
  }