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


C++ Metadata::PlayCount方法代码示例

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


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

示例1: resync

void AllMusic::resync()
{
    m_done_loading = false;

    QString aquery = "SELECT music_songs.song_id, music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, "
                     "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
                     "music_songs.track, music_songs.length, CONCAT_WS('/', "
                     "music_directories.path, music_songs.filename) AS filename, "
                     "music_songs.rating, music_songs.numplays, music_songs.lastplay, music_albums.compilation, "
                     "music_songs.format "
                     "FROM music_songs "
                     "LEFT JOIN music_directories ON music_songs.directory_id=music_directories.directory_id "
                     "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
                     "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
                     "LEFT JOIN music_artists AS music_comp_artists ON music_albums.artist_id=music_comp_artists.artist_id "
                     "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
                     "ORDER BY music_songs.song_id;";

    QString filename, artist, album, title, compartist;

    MSqlQuery query(MSqlQuery::InitCon());
    if (!query.exec(aquery))
        MythDB::DBError("AllMusic::resync", query);

    m_root_node->clear();
    m_all_music.clear();

    m_numPcs = query.size() * 2;
    m_numLoaded = 0;

    if (query.isActive() && query.size() > 0)
    {
        while (query.next())
        {
            filename = query.value(9).toString();
            if (!filename.contains("://"))
                filename = m_startdir + filename;

            Metadata *temp = new Metadata(
                filename,
                query.value(1).toString(),     // artist
                query.value(2).toString(),     // compilation artist
                query.value(3).toString(),     // album
                query.value(4).toString(),     // title
                query.value(5).toString(),     // genre
                query.value(6).toInt(),        // year
                query.value(7).toInt(),        // track no.
                query.value(8).toInt(),        // length
                query.value(0).toInt(),        // id
                query.value(10).toInt(),       // rating
                query.value(11).toInt(),       // playcount
                query.value(12).toDateTime(),  // lastplay
                (query.value(13).toInt() > 0), // compilation
                query.value(14).toString());   // format

            //  Don't delete temp, as PtrList now owns it
            m_all_music.append(temp);

            // compute max/min playcount,lastplay for all music
            if (query.at() == 0)
            {   // first song
                m_playcountMin = m_playcountMax = temp->PlayCount();
                m_lastplayMin  = m_lastplayMax  = temp->LastPlay().toTime_t();
            }
            else
            {
                int playCount = temp->PlayCount();
                double lastPlay = temp->LastPlay().toTime_t();

                m_playcountMin = min(playCount, m_playcountMin);
                m_playcountMax = max(playCount, m_playcountMax);
                m_lastplayMin  = min(lastPlay,  m_lastplayMin);
                m_lastplayMax  = max(lastPlay,  m_lastplayMax);
            }
            m_numLoaded++;
        }
    }
    else
    {
        VERBOSE(VB_IMPORTANT, "MythMusic hasn't found any tracks! "
                "That's ok with me if it's ok with you.");
    }

    //  To find this data quickly, build a map
    //  (a map to pointers!)
    music_map.clear();
    MetadataPtrList::iterator it = m_all_music.begin();
    for (; it != m_all_music.end(); ++it)
        music_map[(*it)->ID()] = *it;

    //  Build a tree to reflect current state of
    //  the metadata. Once built, sort it.

    buildTree();
    sortTree();
    m_done_loading = true;
}
开发者ID:Cougar,项目名称:mythtv,代码行数:97,代码来源:metadata.cpp

示例2: writeTree

int Playlist::writeTree(GenericTree *tree_to_write_to, int a_counter)
{
    // compute max/min playcount,lastplay for this playlist
    int playcountMin = 0;
    int playcountMax = 0;
    double lastplayMin = 0.0;
    double lastplayMax = 0.0;

    typedef map<QString, uint32_t> AlbumMap;
    AlbumMap                       album_map;
    AlbumMap::iterator             Ialbum;
    QString                        album;

    typedef map<QString, uint32_t> ArtistMap;
    ArtistMap                      artist_map;
    ArtistMap::iterator            Iartist;
    QString                        artist;

    uint idx = 0;
    SongList::const_iterator it = songs.begin();
    for (; it != songs.end(); ++it, ++idx)
    {
        if (!(*it)->getCDFlag())
        {
            if ((*it)->getValue() == 0)
            {
                VERBOSE(VB_IMPORTANT, LOC_ERR + kID0err);
            }
            if ((*it)->getValue() > 0)
            {
                // Normal track
                Metadata *tmpdata =
                    all_available_music->getMetadata((*it)->getValue());
                if (tmpdata)
                {
                    if (tmpdata->isVisible())
                    {
                        if (0 == idx)
                        { // first song
                            playcountMin = playcountMax = tmpdata->PlayCount();
                            lastplayMin = lastplayMax = tmpdata->LastPlay().toTime_t();
                        }
                        else
                        {
                            if (tmpdata->PlayCount() < playcountMin)
                                playcountMin = tmpdata->PlayCount();
                            else if (tmpdata->PlayCount() > playcountMax)
                                playcountMax = tmpdata->PlayCount();

                            if (tmpdata->LastPlay().toTime_t() < lastplayMin)
                                lastplayMin = tmpdata->LastPlay().toTime_t();
                            else if (tmpdata->LastPlay().toTime_t() > lastplayMax)
                                lastplayMax = tmpdata->LastPlay().toTime_t();
                        }
                    }
                    // pre-fill the album-map with the album name.
                    // This allows us to do album mode in album order
                    album = tmpdata->Album();
                    // pre-fill the artist map with the artist name and song title
                    artist = tmpdata->Artist() + "~" + tmpdata->Title();
                }
                if ((Ialbum = album_map.find(album)) == album_map.end())
                    album_map.insert(AlbumMap::value_type(album,0));

                if ((Iartist = artist_map.find(artist)) == artist_map.end())
                    artist_map.insert(ArtistMap::value_type(artist,0));
            }
        }
    }
    // populate the sort id into the album map
    uint32_t album_count = 1;
    for (Ialbum = album_map.begin(); Ialbum != album_map.end(); Ialbum++)
    {
        Ialbum->second = album_count;
        album_count++;
    }

    // populate the sort id into the artist map
    uint32_t count = 1;
    for (Iartist = artist_map.begin(); Iartist != artist_map.end(); Iartist++)
    {
        Iartist->second = count;
        count++;
    }

    int RatingWeight = 2;
    int PlayCountWeight = 2;
    int LastPlayWeight = 2;
    int RandomWeight = 2;

    parent->FillIntelliWeights(RatingWeight, PlayCountWeight, LastPlayWeight,
                               RandomWeight);

    for (it = songs.begin(); it != songs.end(); ++it)
    {
        if (!(*it)->getCDFlag())
        {
            if ((*it)->getValue() == 0)
            {
                VERBOSE(VB_IMPORTANT, LOC_ERR + kID0err);
//.........这里部分代码省略.........
开发者ID:Cougar,项目名称:mythtv,代码行数:101,代码来源:playlist.cpp


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