mirror of
https://github.com/taglib/taglib.git
synced 2025-07-19 05:24:25 -04:00
Add support for ID3v2 SYLT frames (synchronized lyrics).
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
#include <textidentificationframe.h>
|
||||
#include <attachedpictureframe.h>
|
||||
#include <unsynchronizedlyricsframe.h>
|
||||
#include <synchronizedlyricsframe.h>
|
||||
#include <generalencapsulatedobjectframe.h>
|
||||
#include <relativevolumeframe.h>
|
||||
#include <popularimeterframe.h>
|
||||
@ -69,6 +70,8 @@ class TestID3v2 : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testRenderUserUrlLinkFrame);
|
||||
CPPUNIT_TEST(testParseOwnershipFrame);
|
||||
CPPUNIT_TEST(testRenderOwnershipFrame);
|
||||
CPPUNIT_TEST(testParseSynchronizedLyricsFrame);
|
||||
CPPUNIT_TEST(testRenderSynchronizedLyricsFrame);
|
||||
CPPUNIT_TEST(testSaveUTF16Comment);
|
||||
CPPUNIT_TEST(testUpdateGenre23_1);
|
||||
CPPUNIT_TEST(testUpdateGenre23_2);
|
||||
@ -427,6 +430,63 @@ public:
|
||||
f.render());
|
||||
}
|
||||
|
||||
void testParseSynchronizedLyricsFrame()
|
||||
{
|
||||
ID3v2::SynchronizedLyricsFrame f(
|
||||
ByteVector("SYLT" // Frame ID
|
||||
"\x00\x00\x00\x21" // Frame size
|
||||
"\x00\x00" // Frame flags
|
||||
"\x00" // Text encoding
|
||||
"eng" // Language
|
||||
"\x02" // Time stamp format
|
||||
"\x01" // Content type
|
||||
"foo\x00" // Content descriptor
|
||||
"Example\x00" // 1st text
|
||||
"\x00\x00\x04\xd2" // 1st time stamp
|
||||
"Lyrics\x00" // 2nd text
|
||||
"\x00\x00\x11\xd7", 43)); // 2nd time stamp
|
||||
CPPUNIT_ASSERT_EQUAL(String::Latin1, f.textEncoding());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("eng", 3), f.language());
|
||||
CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::AbsoluteMilliseconds,
|
||||
f.timestampFormat());
|
||||
CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::Lyrics, f.type());
|
||||
CPPUNIT_ASSERT_EQUAL(String("foo"), f.description());
|
||||
ID3v2::SynchronizedLyricsFrame::SynchedTextList stl = f.synchedText();
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), stl.size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Example"), stl[0].text);
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1234), stl[0].time);
|
||||
CPPUNIT_ASSERT_EQUAL(String("Lyrics"), stl[1].text);
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4567), stl[1].time);
|
||||
}
|
||||
|
||||
void testRenderSynchronizedLyricsFrame()
|
||||
{
|
||||
ID3v2::SynchronizedLyricsFrame f;
|
||||
f.setTextEncoding(String::Latin1);
|
||||
f.setLanguage(ByteVector("eng", 3));
|
||||
f.setTimestampFormat(ID3v2::SynchronizedLyricsFrame::AbsoluteMilliseconds);
|
||||
f.setType(ID3v2::SynchronizedLyricsFrame::Lyrics);
|
||||
f.setDescription("foo");
|
||||
ID3v2::SynchronizedLyricsFrame::SynchedTextList stl;
|
||||
stl.append(ID3v2::SynchronizedLyricsFrame::SynchedText(1234, "Example"));
|
||||
stl.append(ID3v2::SynchronizedLyricsFrame::SynchedText(4567, "Lyrics"));
|
||||
f.setSynchedText(stl);
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
ByteVector("SYLT" // Frame ID
|
||||
"\x00\x00\x00\x21" // Frame size
|
||||
"\x00\x00" // Frame flags
|
||||
"\x00" // Text encoding
|
||||
"eng" // Language
|
||||
"\x02" // Time stamp format
|
||||
"\x01" // Content type
|
||||
"foo\x00" // Content descriptor
|
||||
"Example\x00" // 1st text
|
||||
"\x00\x00\x04\xd2" // 1st time stamp
|
||||
"Lyrics\x00" // 2nd text
|
||||
"\x00\x00\x11\xd7", 43), // 2nd time stamp
|
||||
f.render());
|
||||
}
|
||||
|
||||
void testItunes24FrameSize()
|
||||
{
|
||||
MPEG::File f(TEST_FILE_PATH_C("005411.id3"), false);
|
||||
|
Reference in New Issue
Block a user