当前位置: 首页>>代码示例>>C++>>正文


C++ Tag::setComment方法代码示例

本文整理汇总了C++中taglib::Tag::setComment方法的典型用法代码示例。如果您正苦于以下问题:C++ Tag::setComment方法的具体用法?C++ Tag::setComment怎么用?C++ Tag::setComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在taglib::Tag的用法示例。


在下文中一共展示了Tag::setComment方法的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;
}
开发者ID:stephen-hill,项目名称:musicCube,代码行数:34,代码来源:musikPlugin.cpp

示例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;
}
开发者ID:BackupTheBerlios,项目名称:mediatagtools,代码行数:24,代码来源:mttfile.cpp

示例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;
    }
}
开发者ID:AlbanBedel,项目名称:mixxx,代码行数:78,代码来源:audiotagger.cpp


注:本文中的taglib::Tag::setComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。