Search in sources :

Example 1 with VorbisCommentChapterReader

use of de.danoeh.antennapod.core.util.vorbiscommentreader.VorbisCommentChapterReader in project AntennaPod by AntennaPod.

the class ChapterUtils method readOggChaptersFromInputStream.

private static void readOggChaptersFromInputStream(Playable p, InputStream input) {
    if (BuildConfig.DEBUG)
        Log.d(TAG, "Trying to read chapters from item with title " + p.getEpisodeTitle());
    try {
        VorbisCommentChapterReader reader = new VorbisCommentChapterReader();
        reader.readInputStream(input);
        List<Chapter> chapters = reader.getChapters();
        if (chapters != null) {
            Collections.sort(chapters, new ChapterStartTimeComparator());
            processChapters(chapters, p);
            if (chaptersValid(chapters)) {
                p.setChapters(chapters);
                Log.i(TAG, "Chapters loaded");
            } else {
                Log.e(TAG, "Chapter data was invalid");
            }
        } else {
            Log.i(TAG, "ChapterReader could not find any Ogg vorbis chapters");
        }
    } catch (VorbisCommentReaderException e) {
        e.printStackTrace();
    }
}
Also used : ChapterStartTimeComparator(de.danoeh.antennapod.core.util.comparator.ChapterStartTimeComparator) Chapter(de.danoeh.antennapod.core.feed.Chapter) VorbisCommentReaderException(de.danoeh.antennapod.core.util.vorbiscommentreader.VorbisCommentReaderException) VorbisCommentChapterReader(de.danoeh.antennapod.core.util.vorbiscommentreader.VorbisCommentChapterReader)

Aggregations

Chapter (de.danoeh.antennapod.core.feed.Chapter)1 ChapterStartTimeComparator (de.danoeh.antennapod.core.util.comparator.ChapterStartTimeComparator)1 VorbisCommentChapterReader (de.danoeh.antennapod.core.util.vorbiscommentreader.VorbisCommentChapterReader)1 VorbisCommentReaderException (de.danoeh.antennapod.core.util.vorbiscommentreader.VorbisCommentReaderException)1