Added support for links in vorbis comment

This commit is contained in:
daniel oeh 2012-11-09 19:40:10 +01:00
parent 8cf119ce7f
commit 1210c7a8a4
1 changed files with 9 additions and 6 deletions

View File

@ -43,12 +43,13 @@ public class VorbisCommentChapterReader extends VorbisCommentReader {
if (AppConfig.DEBUG) if (AppConfig.DEBUG)
Log.d(TAG, "Key: " + key + ", value: " + value); Log.d(TAG, "Key: " + key + ", value: " + value);
String attribute = VorbisCommentChapter.getAttributeTypeFromKey(key); String attribute = VorbisCommentChapter.getAttributeTypeFromKey(key);
int id = VorbisCommentChapter.getIDFromKey(key);
Chapter chapter = getChapterById(id);
if (attribute == null) { if (attribute == null) {
int id = VorbisCommentChapter.getIDFromKey(key);
if (getChapterById(id) == null) { if (getChapterById(id) == null) {
// new chapter // new chapter
long start = VorbisCommentChapter.getStartTimeFromValue(value); long start = VorbisCommentChapter.getStartTimeFromValue(value);
VorbisCommentChapter chapter = new VorbisCommentChapter(id); chapter = new VorbisCommentChapter(id);
chapter.setStart(start); chapter.setStart(start);
chapters.add(chapter); chapters.add(chapter);
} else { } else {
@ -57,10 +58,12 @@ public class VorbisCommentChapterReader extends VorbisCommentReader {
+ value + ")"); + value + ")");
} }
} else if (attribute.equals(CHAPTER_ATTRIBUTE_TITLE)) { } else if (attribute.equals(CHAPTER_ATTRIBUTE_TITLE)) {
int id = VorbisCommentChapter.getIDFromKey(key); if (chapter != null) {
Chapter c = getChapterById(id); chapter.setTitle(value);
if (c != null) { }
c.setTitle(value); } else if (attribute.equals(CHAPTER_ATTRIBUTE_LINK)) {
if (chapter != null) {
chapter.setLink(value);
} }
} }
} }