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


C++ FileRef::audioProperties方法代码示例

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


在下文中一共展示了FileRef::audioProperties方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tuneFromFile

Tune* tuneFromFile(const QString& file)
{
	Tune* tune = new Tune(false);
	tune->file = file;

	TagLib::FileRef ref = fileName2TaglibRef(file);
	if(!ref.isNull()) {
		if(ref.tag()) {
			TagLib::Tag* tag = ref.tag();
			tune->artist = safeTagLibString2QString( tag->artist() );
			tune->album = safeTagLibString2QString( tag->album() );
			tune->title = safeTagLibString2QString( tag->title() );
			tune->trackNumber = QString::number( tag->track() );
			tune->genre = safeTagLibString2QString( tag->genre() );
		}

		Qomp::loadCover(tune, ref.file());

		if(ref.audioProperties()) {
			TagLib::AudioProperties *prop = ref.audioProperties();
			tune->duration = Qomp::durationSecondsToString( prop->length() );
			tune->bitRate = QString::number( prop->bitrate() );
		}

		tune->setMetadataResolved(true);
	}

	return tune;
}
开发者ID:qomp,项目名称:qomp,代码行数:29,代码来源:taghelpers.cpp

示例2: getAudioInfo

bool getAudioInfo(const QString& file, qint64* durationMiliSecs, int* bitrate)
{
	TagLib::FileRef ref = Qomp::fileName2TaglibRef(file);
	if(!ref.isNull() && ref.audioProperties()) {
		TagLib::AudioProperties *prop = ref.audioProperties();

		*bitrate = prop->bitrate();
		*durationMiliSecs = prop->length() * 1000;

		return true;
	}

	return false;
}
开发者ID:qomp,项目名称:qomp,代码行数:14,代码来源:taghelpers.cpp

示例3: p_mp4_header

/**
 * MPEG-4:
 * Video Codecs:
 *    H.264 Baseline: avc1.42E0xx, where xx is the AVC level
 *    H.264 Main: avc1.4D40xx, where xx is the AVC level
 *    H.264 High: avc1.6400xx, where xx is the AVC level
 *    MPEG-4 Visual Simple Profile Level 0: mp4v.20.9
 *    MPEG-4 Visual Advanced Simple Profile Level 0: mp4v.20.240
 * Audio Codecs:
 *    Low-Complexity AAC: mp4a.40.2
 */
void p_mp4_header(TagLib::FileRef f)
{
    TagLib::String title = f.tag()->title();
    TagLib::String artist = f.tag()->artist();
    TagLib::String album = f.tag()->album();
    TagLib::String comment = f.tag()->comment();
    TagLib::String genre = f.tag()->genre();
    TagLib::uint year = f.tag()->year();
    TagLib::uint track = f.tag()->track();
    TagLib::MP4::Properties *prop = (TagLib::MP4::Properties*) f.audioProperties();
    TagLib::MP4::Properties::Codec codec = prop->codec();

    printf("Metadata\n");
    printf("Artist    :  %s\nTitle     :  %s\nAlbum     :  %s\nGenre     :  %s\n",
            artist.toCString(true),
            title.toCString(true),
            album.toCString(true),
            genre.toCString(true));
    printf("Comment   :  %s\nYear      :  %d\nTrack     :  %d\n",
            comment.toCString(true),
            year, track);
    printf("Length    :  %d\nBitrate   :  %d\nS' Rate   :  %d\nChannels  :  %d\n",
            prop->length(),
            prop->bitrate(),
            prop->sampleRate(),
            prop->channels());
    printf("BPS       :  %d\nEncrypted :  %d\nAudio Codec  :  %s\n",
            prop->bitsPerSample(),
            prop->isEncrypted(),
            mp4_codec_str[codec]);
}
开发者ID:tzyluen,项目名称:h.264tzy,代码行数:42,代码来源:mp4.cpp

示例4: readTags

void Track::readTags()
{
    QByteArray fileName = QFile::encodeName( p->url.toLocalFile() );
    const char * encodedName = fileName.constData();
    TagLib::FileRef fileref = TagLib::FileRef( encodedName, true, TagLib::AudioProperties::Fast);

   if ( !fileref.isNull() )
   {
        if( fileref.tag() )
        {
            TagLib::Tag *tag = fileref.tag();

            p->title   = !tag->title().isNull() ? TStringToQString( tag->title() ).trimmed() : QObject::tr("Unknown");
            p->artist  = !tag->artist().isNull() ? TStringToQString( tag->artist() ).trimmed() : QObject::tr("Unknown");
            p->album   = !tag->album().isNull() ? TStringToQString( tag->album() ).trimmed() : QObject::tr("Unknown");
            p->comment = TStringToQString( tag->comment() ).trimmed();
            p->genre   = !tag->genre().isNull() ? TStringToQString( tag->genre() ).trimmed() : QObject::tr("Unknown");
            p->year    = tag->year() ? QString::number( tag->year() ) : QString::null;
            p->tracknumber   = tag->track() ? QString::number( tag->track() ) : QString::null;
            p->length     = fileref.audioProperties()->length();
            p->counter = 0;
            p->rate = 0;

            //polish up empty tags
            if( p->title == QObject::tr("Unknown") ) {
                QFileInfo fileInfo(p->url.toLocalFile());
                p->title = fileInfo.fileName().replace( '_', ' ' ).replace('.' + fileInfo.suffix(),"") ;
            }
        }
    }

}
开发者ID:intfrr,项目名称:knowthelist,代码行数:32,代码来源:track.cpp

示例5: getTrackLength

/*!
* \brief Find the length of the track (in seconds)
*
* \param filename The filename for which we want to find the length.
* \returns An integer (signed!) to represent the length in milliseconds.
*/
int MetaIOTagLib::getTrackLength(const QString &filename)
{
    int milliseconds = 0;
    QByteArray fname = filename.toLocal8Bit();
    TagLib::FileRef *file = new TagLib::FileRef(fname.constData());

    if (file && file->audioProperties())
        milliseconds = file->audioProperties()->length() * 1000;

    // If we didn't get a valid length, add the metadata but show warning.
    if (milliseconds <= 1000)
        LOG(VB_GENERAL, LOG_ERR,
            QString("MetaIOTagLib: Failed to read length "
                    "from '%1'. It may be corrupt.").arg(filename));
    
    return milliseconds;
}
开发者ID:JackOfMostTrades,项目名称:mythtv,代码行数:23,代码来源:metaiotaglib.cpp

示例6: eval

BlockResult Block::eval(const TagLib::FileRef& file)
{
    TagLib::PropertyMap metadata = file.tag()->properties();
    TagLib::StringList list;
    std::stringstream ss;
    // TODO: Needs to be refactored
    // TODO: Add more
    ss << file.audioProperties()->length();
    list.append(ss.str());
    metadata.insert("length", list);
    list.clear();
    ss.clear();

    ss << file.audioProperties()->bitrate();
    list.append(ss.str());
    metadata.insert("bitrate", list);
    list.clear();
    ss.clear();

    if (file.audioProperties()->channels() == 1) {
        list.append("mono");
    } else if (file.audioProperties()->channels() == 2) {
        list.append("stereo");
    } //TODO: Add more channels names

    metadata.insert("channels", list);
    list.clear();
    ss.clear();

    ss << file.audioProperties()->sampleRate();
    list.append(ss.str());
    metadata.insert("samplerate", list);
    list.clear();
    ss.clear();

    list.append(file.file()->name());
    metadata.insert("filename", list);
    list.clear();
    ss.clear();

    return this->eval(metadata);
}
开发者ID:zyphrus,项目名称:libfb2k,代码行数:42,代码来源:Block.cpp

示例7: AddFromFile_Taglib

// Use Taglib to parse tags from file and add entried to wxListCtrl
void AddFromFile_Taglib(wxListCtrl *listctrl, const std::map< wxString, long > &mapping, const wxString &filename)
{
    TagLib::FileRef f = TagLib::FileRef(filename.c_str(), TagLib::String::UTF8 ); //TODO: is c_str() safe?

    if ( f.isNull() )
    {
        wxLogError(wxT("Error: TagLib could not read ") + filename + wxT("."));
        return;
    }

    if ( ! f.tag() )
    {
        wxLogError(wxT("Error: TagLib could not read the tags of file ") + filename + wxT("."));
        return;
    }

    TagLib::Tag *tag = f.tag();
    auto idx = listctrl->GetItemCount();
    auto row_idx = listctrl->InsertItem(idx, wxString::Format(wxT("%d"), idx) );

    // TODO: check return values
    listctrl->SetItem(row_idx, mapping.find("Artist")->second, wxString(tag->artist().to8Bit(true)) );
    listctrl->SetItem(row_idx, mapping.find("Trackname")->second, wxString(tag->title().to8Bit(true)));
    listctrl->SetItem(row_idx, mapping.find("Album")->second, wxString(tag->album().to8Bit(true)));

    if ( f.audioProperties() )
    {
      TagLib::AudioProperties *properties = f.audioProperties();
      int seconds = properties->length() % 60;
      int minutes = (properties->length() - seconds) / 60;

      wxString timestr = wxString::Format("%d:%02d", minutes, seconds);

      listctrl->SetItem(row_idx, mapping.find("Time")->second, timestr);
    }

}
开发者ID:sperrholz,项目名称:lfmt,代码行数:38,代码来源:lfmt_util.cpp

示例8: readInfo

void MediaInfo::readInfo(TagLib::FileRef f) {
    bitrate = f.audioProperties() -> bitrate();
    channels = f.audioProperties() -> channels();
    duration = f.audioProperties() -> length();
    sampleRate = f.audioProperties() -> sampleRate();
}
开发者ID:jeyboy,项目名称:palyo2,代码行数:6,代码来源:mediainfo.cpp


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