コード例 #1
0
  private void addChapterFolder(DLNAResource dlna) {
    if (!dlna.getFormat().isVideo()) {
      return;
    }

    int chapterInterval =
        configuration.isChapterSupport() ? configuration.getChapterInterval() : -1;

    if ((chapterInterval > 0) && isSeekable(dlna)) {
      // don't add a chapter folder if the duration of the video
      // is less than the chapter length.
      double duration = dlna.getMedia().getDurationInSeconds(); // 0 if the duration is unknown
      if (duration != 0 && duration <= (chapterInterval * 60)) {
        return;
      }

      ChapterFileTranscodeVirtualFolder chapterFolder =
          new ChapterFileTranscodeVirtualFolder(
              String.format(
                  Messages.getString("FileTranscodeVirtualFolder.1"), dlna.getDisplayName()),
              null,
              chapterInterval);
      DLNAResource copy = dlna.clone();
      copy.setNoName(true);
      chapterFolder.addChildInternal(copy);
      addChildInternal(chapterFolder);
    }
  }
コード例 #2
0
  /**
   * Create a copy of the provided original resource and optionally set the copy's audio track,
   * subtitle track and player.
   *
   * @param original The original {@link DLNAResource} to create a copy of.
   * @param audio The audio track to use.
   * @param subtitle The subtitle track to use.
   * @param player The player to use.
   * @return The copy.
   */
  private DLNAResource createResourceWithAudioSubtitlePlayer(
      DLNAResource original, DLNAMediaAudio audio, DLNAMediaSubtitle subtitle, Player player) {
    // FIXME clone is broken. should be e.g. original.newInstance()
    DLNAResource copy = original.clone();
    copy.setMedia(original.getMedia());
    copy.setNoName(true);
    copy.setMediaAudio(audio);
    copy.setMediaSubtitle(subtitle);
    copy.setPlayer(player);

    return copy;
  }