示例#1
0
Meta::FieldHash
MP4TagHelper::tags() const
{
    Meta::FieldHash data = TagHelper::tags();

    TagLib::MP4::ItemListMap map = m_tag->itemListMap();
    for( TagLib::MP4::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it )
    {
        qint64 field;
        QString value = TStringToQString( it->second.toStringList().toString( '\n' ) );
        if( ( field = fieldName( it->first ) ) )
        {
            if( field == Meta::valHasCover )
            {
                TagLib::MP4::CoverArtList coverList = it->second.toCoverArtList();
                for( TagLib::MP4::CoverArtList::ConstIterator it = coverList.begin(); it != coverList.end(); ++it )
                    if( it->data().size() > MIN_COVER_SIZE )
                    {
                        data.insert( field, true );
                        break;
                    }
            }

            // http://gitorious.org/~jefferai/xdg-specs/jefferais-xdg-specs/blobs/mediaspecs/specifications/FMPSpecs/specification.txt sais that mp4 tags should be saved as strings
            else if( field == Meta::valPlaycount )
                data.insert( field, value.toInt() );
            else if( field == Meta::valRating )
                data.insert( field, qRound( value.toFloat() * 10.0 ) );
            else if( field == Meta::valScore )
                data.insert( field, value.toFloat() * 100.0 );

            else if( field == Meta::valBpm )
                data.insert( field, it->second.toInt() );
            else if( field == Meta::valDiscNr )
                data.insert( field, it->second.toIntPair().first );

            else if( field == Meta::valCompilation )
                data.insert( field, it->second.toBool() );
            else
                data.insert( field, value );
        }
        else if( it->first == uidFieldName( UIDAFT ) && isValidUID( value, UIDAFT ) )
            data.insert( Meta::valUniqueId, value );
    }

    return data;
}
示例#2
0
QImage
MP4TagHelper::embeddedCover() const
{
    TagLib::MP4::ItemListMap map = m_tag->itemListMap();
    TagLib::String name = fieldName( Meta::valHasCover );
    for( TagLib::MP4::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it )
    {
        if( it->first == name )
        {
            TagLib::MP4::CoverArtList coverList = it->second.toCoverArtList();
            for( TagLib::MP4::CoverArtList::Iterator cover = coverList.begin(); cover != coverList.end(); ++cover )
            {
                if( cover->data().size() > MIN_COVER_SIZE )
                    return QImage::fromData( ( uchar * ) cover->data().data(), cover->data().size() );
            }
        }
    }

    return QImage();
}