use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class ChapterReaderTest method testRealFileHindenburgJournalistPro.
@Test
public void testRealFileHindenburgJournalistPro() throws IOException, ID3ReaderException {
CountingInputStream inputStream = new CountingInputStream(getClass().getClassLoader().getResource("hindenburg-journalist-pro.mp3").openStream());
ChapterReader reader = new ChapterReader(inputStream);
reader.readInputStream();
List<Chapter> chapters = reader.getChapters();
assertEquals(2, chapters.size());
assertEquals(0, chapters.get(0).getStart());
assertEquals(5006, chapters.get(1).getStart());
assertEquals("Chapter Marker 1", chapters.get(0).getTitle());
assertEquals("Chapter Marker 2", chapters.get(1).getTitle());
assertEquals("https://example.com/chapter1url", chapters.get(0).getLink());
assertEquals("https://example.com/chapter2url", chapters.get(1).getLink());
assertEquals(EmbeddedChapterImage.makeUrl(5330, 4015), chapters.get(0).getImageUrl());
assertEquals(EmbeddedChapterImage.makeUrl(9498, 4364), chapters.get(1).getImageUrl());
}
use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class VorbisCommentChapterReader method onContentVectorValue.
@Override
public void onContentVectorValue(String key, String value) throws VorbisCommentReaderException {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Key: " + key + ", value: " + value);
}
String attribute = VorbisCommentChapter.getAttributeTypeFromKey(key);
int id = VorbisCommentChapter.getIDFromKey(key);
Chapter chapter = getChapterById(id);
if (attribute == null) {
if (getChapterById(id) == null) {
// new chapter
long start = VorbisCommentChapter.getStartTimeFromValue(value);
chapter = new VorbisCommentChapter(id);
chapter.setStart(start);
chapters.add(chapter);
} else {
throw new VorbisCommentReaderException("Found chapter with duplicate ID (" + key + ", " + value + ")");
}
} else if (attribute.equals(CHAPTER_ATTRIBUTE_TITLE)) {
if (chapter != null) {
chapter.setTitle(value);
}
} else if (attribute.equals(CHAPTER_ATTRIBUTE_LINK)) {
if (chapter != null) {
chapter.setLink(value);
}
}
}
use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class ChapterReaderTest method testReadChapterWithTitle.
@Test
public void testReadChapterWithTitle() throws IOException, ID3ReaderException {
byte[] title = { ID3Reader.ENCODING_ISO, // Title
'H', // Title
'e', // Title
'l', // Title
'l', // Title
'o', // Null-terminated
0 };
byte[] chapterData = Id3ReaderTest.concat(CHAPTER_WITHOUT_SUBFRAME, Id3ReaderTest.generateFrameHeader(ChapterReader.FRAME_ID_TITLE, title.length), title);
FrameHeader header = new FrameHeader(ChapterReader.FRAME_ID_CHAPTER, chapterData.length, (short) 0);
CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(chapterData));
ChapterReader reader = new ChapterReader(inputStream);
Chapter chapter = reader.readChapter(header);
assertEquals(CHAPTER_WITHOUT_SUBFRAME_START_TIME, chapter.getStart());
assertEquals("Hello", chapter.getTitle());
}
use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class DBReader method loadChaptersOfFeedItem.
private static List<Chapter> loadChaptersOfFeedItem(PodDBAdapter adapter, FeedItem item) {
try (Cursor cursor = adapter.getSimpleChaptersOfFeedItemCursor(item)) {
int chaptersCount = cursor.getCount();
if (chaptersCount == 0) {
item.setChapters(null);
return null;
}
ArrayList<Chapter> chapters = new ArrayList<>();
while (cursor.moveToNext()) {
chapters.add(ChapterCursorMapper.convert(cursor));
}
return chapters;
}
}
use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class ChaptersListAdapter method setMedia.
public void setMedia(Playable media) {
this.media = media;
hasImages = false;
if (media.getChapters() != null) {
for (Chapter chapter : media.getChapters()) {
if (!TextUtils.isEmpty(chapter.getImageUrl())) {
hasImages = true;
}
}
}
notifyDataSetChanged();
}
Aggregations