Example #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;
  }