added id3 tag recognition to UploadFileWindow
This commit is contained in:
parent
a4c3aa0fc4
commit
e806ca5f3b
4 changed files with 76 additions and 48 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.27 $
|
||||
Version : $Revision: 1.28 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -610,11 +610,18 @@ AudioClip :: readTag(Ptr<MetadataTypeContainer>::Ref metadataTypes)
|
|||
throw std::invalid_argument("audio clip has no uri field");
|
||||
}
|
||||
|
||||
if (!TagLib::File::isReadable(getUri()->c_str())) {
|
||||
std::string uri = *getUri();
|
||||
if (uri.substr(0,7) == "file://") {
|
||||
uri = uri.substr(7);
|
||||
} else if (uri.substr(0,5) == "file:") {
|
||||
uri = uri.substr(5);
|
||||
}
|
||||
|
||||
if (!TagLib::File::isReadable(uri.c_str())) {
|
||||
throw std::invalid_argument("binary sound file not found");
|
||||
}
|
||||
|
||||
TagLib::MPEG::File mpegFile(getUri()->c_str());
|
||||
TagLib::MPEG::File mpegFile(uri.c_str());
|
||||
TagLib::ID3v2::Tag* id3v2Tag = mpegFile.ID3v2Tag();
|
||||
if (id3v2Tag) {
|
||||
Ptr<const MetadataType>::Ref metadata;
|
||||
|
@ -641,7 +648,7 @@ AudioClip :: readTag(Ptr<MetadataTypeContainer>::Ref metadataTypes)
|
|||
return;
|
||||
}
|
||||
|
||||
TagLib::FileRef genericFileRef(getUri()->c_str());
|
||||
TagLib::FileRef genericFileRef(uri.c_str());
|
||||
TagLib::Tag* tag = genericFileRef.tag();
|
||||
if (tag) {
|
||||
TagLib::String stringValue;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.14 $
|
||||
Version : $Revision: 1.15 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClipTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -210,6 +210,7 @@ void
|
|||
AudioClipTest :: tagTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
// should work with either plain file path...
|
||||
Ptr<std::string>::Ref uri(new std::string("var/test10001.mp3"));
|
||||
audioClip->setUri(uri);
|
||||
try {
|
||||
|
@ -225,6 +226,21 @@ AudioClipTest :: tagTest(void)
|
|||
Ptr<const Glib::ustring>::Ref artist
|
||||
= audioClip->getMetadata("dc:creator");
|
||||
CPPUNIT_ASSERT(*artist == "The Muppets");
|
||||
|
||||
// ... or with URI
|
||||
uri.reset(new std::string("file:var/test10001.mp3"));
|
||||
audioClip->setUri(uri);
|
||||
try {
|
||||
audioClip->readTag(metadataTypes);
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
title = audioClip->getMetadata("dc:title");
|
||||
CPPUNIT_ASSERT(*title == "Theme Song");
|
||||
|
||||
artist = audioClip->getMetadata("dc:creator");
|
||||
CPPUNIT_ASSERT(*artist == "The Muppets");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue