private boolean isSeekable(DLNAResource dlna) {
    Player player = dlna.getPlayer();

    if ((player == null) || player.isTimeSeekable()) {
      return true;
    } else {
      return false;
    }
  }
Exemplo n.º 2
0
 /**
  * Returns whether or not another player has the same name and id as this one.
  *
  * @param other The other player.
  * @return True if names and ids match, false otherwise.
  */
 @Override
 public boolean equals(Object other) {
   if (other == null || !(other instanceof Player)) {
     return false;
   }
   if (other == this) {
     return true;
   }
   Player otherPlayer = (Player) other;
   return (otherPlayer.name().equals(this.name()) && otherPlayer.id().equals(this.id()));
 }
  /**
   * Returns the player that matches the given class and format.
   *
   * @param profileClass The class to match.
   * @param ext The format to match.
   * @return The player if a match could be found, <code>null</code> otherwise.
   */
  public static Player getPlayer(final Class<? extends Player> profileClass, final Format ext) {

    for (Player player : players) {
      if (player.getClass().equals(profileClass)
          && player.type() == ext.getType()
          && !player.excludeFormat(ext)) {
        return player;
      }
    }

    return null;
  }
  /**
   * Returns the players matching the given classes and type.
   *
   * @param profileClasses The classes to match.
   * @param type The type to match.
   * @return The list of players that match. If no players match, an empty list is returned.
   */
  public static ArrayList<Player> getPlayers(
      final ArrayList<Class<? extends Player>> profileClasses, final int type) {

    ArrayList<Player> compatiblePlayers = new ArrayList<Player>();

    for (Player player : players) {
      if (profileClasses.contains(player.getClass()) && player.type() == type) {
        compatiblePlayers.add(player);
      }
    }

    return compatiblePlayers;
  }
  public void addEngines() {
    ArrayList<Player> disPlayers = new ArrayList<Player>();
    ArrayList<Player> ordPlayers = new ArrayList<Player>();
    PMS r = PMS.get();

    for (String id : configuration.getEnginesAsList(r.getRegistry())) {
      // boolean matched = false;
      for (Player p : PlayerFactory.getAllPlayers()) {
        if (p.id().equals(id)) {
          ordPlayers.add(p);
          // matched = true;
        }
      }
    }

    for (Player p : PlayerFactory.getAllPlayers()) {
      if (!ordPlayers.contains(p)) {
        ordPlayers.add(p);
        disPlayers.add(p);
      }
    }

    for (Player p : ordPlayers) {
      TreeNodeSettings en = new TreeNodeSettings(p.name(), p, null);
      if (disPlayers.contains(p)) {
        en.setEnable(false);
      }
      JComponent jc = en.getConfigPanel();
      if (jc == null) {
        jc = buildEmpty();
      }
      jc.addComponentListener(
          new ComponentAdapter() {
            @Override
            public void componentShown(ComponentEvent e) {
              handleCardComponentChange(e.getComponent());
            }
          });
      tabbedPane.add(en.id(), jc);
      parent[p.purpose()].add(en);
    }

    for (int i = 0; i < tree.getRowCount(); i++) {
      tree.expandRow(i);
    }

    tree.setSelectionRow(0);
  }
  /**
   * Adds a single {@link Player} to the list of Players. Before the player is added to the list, it
   * is verified to be okay.
   *
   * @param player Player to be added to the list.
   */
  public static synchronized void registerPlayer(final Player player) {
    boolean ok = false;
    allPlayers.add(player);

    if (Player.NATIVE.equals(player.executable())) {
      ok = true;
    } else {
      if (Platform.isWindows()) {
        if (player.executable() == null) {
          LOGGER.info("Executable of transcoder profile " + player + " not defined");
          return;
        }

        File executable = new File(player.executable());
        File executable2 = new File(player.executable() + ".exe");

        if (executable.exists() || executable2.exists()) {
          ok = true;
        } else {
          LOGGER.info("Executable of transcoder profile " + player + " not found");
          return;
        }

        if (player.avisynth()) {
          ok = false;

          if (utils.isAvis()) {
            ok = true;
          } else {
            LOGGER.info(
                "Transcoder profile "
                    + player
                    + " will not be used because AviSynth was not found");
          }
        }
      } else if (!player.avisynth()) {
        ok = true;
      }
    }

    if (ok) {
      LOGGER.info("Registering transcoding engine: " + player);
      players.add(player);
    }
  }