本文整理汇总了C++中taglib::Tag::setGenre方法的典型用法代码示例。如果您正苦于以下问题:C++ Tag::setGenre方法的具体用法?C++ Tag::setGenre怎么用?C++ Tag::setGenre使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglib::Tag
的用法示例。
在下文中一共展示了Tag::setGenre方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteTag
bool WriteTag(const musik::Core::SongInfo& info)
{
bool ret = true;
try
{
#if defined (WIN32)
TagLib::FileRef tag_file(info.GetFilename().c_str());
#else
TagLib::FileRef tag_file(utf16to8(info.GetFilename(), true).c_str());
#endif
if (!tag_file.isNull())
{
TagLib::Tag *tag = tag_file.tag();
tag->setArtist(info.GetArtist().c_str());
tag->setAlbum(info.GetAlbum().c_str());
tag->setTitle(info.GetTitle().c_str());
tag->setGenre(info.GetGenre().c_str());
tag->setYear(musik::Core::StringToInt(info.GetYear()));
tag->setTrack(musik::Core::StringToInt(info.GetTrackNum()));
tag->setComment(info.GetNotes().c_str());
tag_file.save();
}
}
catch (...)
{
ret = false;
cout << "taglib crashed trying to write: " << info.GetFilename().c_str() << endl;
}
return ret;
}
示例2: removeTag
void mttFile::removeTag( void )
{
fileref = new TagLib::FileRef( QFile::encodeName( fname ).constData() );
if ( ismpeg ) {
TagLib::MPEG::File *f = dynamic_cast<TagLib::MPEG::File *>(fileref->file());
f->strip();
}
else {
TagLib::Tag *intag = fileref->tag();
intag->setTitle( TagLib::String::null );
intag->setArtist( TagLib::String::null );
intag->setAlbum( TagLib::String::null );
intag->setComment( TagLib::String::null );
intag->setGenre( TagLib::String::null );
intag->setYear( 0 );
intag->setTrack( 0 );
fileref->save();
}
delete fileref;
fileref = NULL;
}
示例3: save
bool AudioTagger::save () {
TagLib::File* file = NULL;
if (m_file.endsWith(".mp3", Qt::CaseInsensitive)) {
file = new TagLib::MPEG::File(m_file.toUtf8().constData());
//process special ID3 fields, APEv2 fiels, etc
//If the mp3 has no ID3v2 tag, we create a new one and add the TBPM and TKEY frame
addID3v2Tag( ((TagLib::MPEG::File*) file)->ID3v2Tag(true) );
//If the mp3 has an APE tag, we update
addAPETag( ((TagLib::MPEG::File*) file)->APETag(false) );
}
if (m_file.endsWith(".m4a", Qt::CaseInsensitive)) {
file = new TagLib::MP4::File(m_file.toUtf8().constData());
//process special ID3 fields, APEv2 fiels, etc
processMP4Tag(((TagLib::MP4::File*) file)->tag());
}
if (m_file.endsWith(".ogg", Qt::CaseInsensitive)) {
file = new TagLib::Ogg::Vorbis::File(m_file.toUtf8().constData());
//process special ID3 fields, APEv2 fiels, etc
addXiphComment( ((TagLib::Ogg::Vorbis::File*) file)->tag() );
}
if (m_file.endsWith(".wav", Qt::CaseInsensitive)) {
file = new TagLib::RIFF::WAV::File(m_file.toUtf8().constData());
//If the flac has no ID3v2 tag, we create a new one and add the TBPM and TKEY frame
addID3v2Tag( ((TagLib::RIFF::WAV::File*) file)->tag() );
}
if (m_file.endsWith(".flac", Qt::CaseInsensitive)) {
file = new TagLib::FLAC::File(m_file.toUtf8().constData());
//If the flac has no ID3v2 tag, we create a new one and add the TBPM and TKEY frame
addID3v2Tag( ((TagLib::FLAC::File*) file)->ID3v2Tag(true) );
//If the flac has no APE tag, we create a new one and add the TBPM and TKEY frame
addXiphComment( ((TagLib::FLAC::File*) file)->xiphComment (true) );
}
if (m_file.endsWith(".aif", Qt::CaseInsensitive) || m_file.endsWith(".aiff", Qt::CaseInsensitive)) {
file = new TagLib::RIFF::AIFF::File(m_file.toUtf8().constData());
//If the flac has no ID3v2 tag, we create a new one and add the TBPM and TKEY frame
addID3v2Tag( ((TagLib::RIFF::AIFF::File*) file)->tag() );
}
//process standard tags
if (file) {
TagLib::Tag *tag = file->tag();
if (tag) {
tag->setArtist(m_artist.toStdString());
tag->setTitle(m_title.toStdString());
tag->setAlbum(m_album.toStdString());
tag->setGenre(m_genre.toStdString());
tag->setComment(m_comment.toStdString());
uint year = m_year.toUInt();
if (year > 0)
tag->setYear(year);
uint tracknumber = m_tracknumber.toUInt();
if (tracknumber > 0)
tag->setTrack(tracknumber);
}
//write audio tags to file
int success = file->save();
if (success) {
qDebug() << "Successfully updated metadata of track " << m_file;
} else {
qDebug() << "Could not update metadata of track " << m_file;
}
//delete file and return
delete file;
return success;
} else {
return false;
}
}