mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Handle WM/TrackNumber with DWORD content
The default type for this attribute is String, but even MSDN suggests to support also DWORD, because some applications write such files. BUG:218526 git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1062026 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
parent
004551faec
commit
74c3c282c4
@ -105,8 +105,13 @@ ASF::Tag::year() const
|
||||
unsigned int
|
||||
ASF::Tag::track() const
|
||||
{
|
||||
if(d->attributeListMap.contains("WM/TrackNumber"))
|
||||
return d->attributeListMap["WM/TrackNumber"][0].toString().toInt();
|
||||
if(d->attributeListMap.contains("WM/TrackNumber")) {
|
||||
const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0];
|
||||
if(attr.type() == ASF::Attribute::DWordType)
|
||||
return attr.toUInt();
|
||||
else
|
||||
return attr.toString().toInt();
|
||||
}
|
||||
if(d->attributeListMap.contains("WM/Track"))
|
||||
return d->attributeListMap["WM/Track"][0].toUInt();
|
||||
return 0;
|
||||
|
@ -18,6 +18,7 @@ class TestASF : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testSaveMultipleValues);
|
||||
CPPUNIT_TEST(testSaveStream);
|
||||
CPPUNIT_TEST(testSaveLanguage);
|
||||
CPPUNIT_TEST(testDWordTrackNumber);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -55,6 +56,32 @@ public:
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testDWordTrackNumber()
|
||||
{
|
||||
ScopedFileCopy copy("silence-1", ".wma");
|
||||
string newname = copy.fileName();
|
||||
|
||||
ASF::File *f = new ASF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT(!f->tag()->attributeListMap().contains("WM/TrackNumber"));
|
||||
f->tag()->setAttribute("WM/TrackNumber", (unsigned int)(123));
|
||||
f->save();
|
||||
delete f;
|
||||
|
||||
f = new ASF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber"));
|
||||
CPPUNIT_ASSERT_EQUAL(ASF::Attribute::DWordType, f->tag()->attributeListMap()["WM/TrackNumber"].front().type());
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(123), f->tag()->track());
|
||||
f->tag()->setTrack(234);
|
||||
f->save();
|
||||
delete f;
|
||||
|
||||
f = new ASF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber"));
|
||||
CPPUNIT_ASSERT_EQUAL(ASF::Attribute::UnicodeType, f->tag()->attributeListMap()["WM/TrackNumber"].front().type());
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(234), f->tag()->track());
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testSaveStream()
|
||||
{
|
||||
ScopedFileCopy copy("silence-1", ".wma");
|
||||
|
Loading…
x
Reference in New Issue
Block a user