예제 #1
0
  /**
   * Analyzes a DVD track and returns all chapters.
   *
   * @param trackNr Track number to be analyzed, starting from 1
   * @return List of {@link Chapter} entities
   */
  public List<Chapter> getChapters(int trackNr) {
    if (trackNr <= 0) {
      return Collections.emptyList();
    }

    DvdTitle title = info.getTitle(trackNr - 1);
    int chapters = title.getChapters();

    List<Chapter> result = new ArrayList<>();

    long ms = 0;
    int chapter = 1;
    for (long time : title.getChapterTimeMs()) {
      result.add(createChapter(chapter++, ms, chapters));
      ms += time;
    }
    result.add(createChapter(chapter, ms, chapters));

    return result;
  }
예제 #2
0
  /** Gets a description of all {@link Track} of the DVD. */
  public Track[] getTracks() {
    Track[] result = new Track[info.getTitles().size()];

    for (int ix = 0; ix < result.length; ix++) {
      DvdTitle title = info.getTitle(ix);
      DvdTitleSet vts = title.getTitleSet();

      Track track = new Track();
      track.setTrack(title.getTitle());
      track.setAngles(title.getAngles());
      track.setChapters(title.getChapters());
      track.setDimension(new Dimension(vts.getWidth(), vts.getHeight()));

      long lengthSec = title.getTotalTimeMs() / 1000L;
      track.setLength(String.format("%d:%02d", (int) (lengthSec / 60), (int) (lengthSec % 60)));
      track.setAspect(AspectRatio.valueOf(vts.getAspect().name()));

      result[ix] = track;
    }

    return result;
  }