本文整理汇总了C++中MusicMetadata::PlayCount方法的典型用法代码示例。如果您正苦于以下问题:C++ MusicMetadata::PlayCount方法的具体用法?C++ MusicMetadata::PlayCount怎么用?C++ MusicMetadata::PlayCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MusicMetadata
的用法示例。
在下文中一共展示了MusicMetadata::PlayCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shuffleTracks
void Playlist::shuffleTracks(MusicPlayer::ShuffleMode shuffleMode)
{
m_shuffledSongs.clear();
switch (shuffleMode)
{
case MusicPlayer::SHUFFLE_RANDOM:
{
QMultiMap<int, MusicMetadata*> songMap;
SongList::const_iterator it = m_songs.begin();
for (; it != m_songs.end(); ++it)
{
songMap.insert(rand(), *it);
}
QMultiMap<int, MusicMetadata*>::const_iterator i = songMap.constBegin();
while (i != songMap.constEnd())
{
m_shuffledSongs.append(i.value());
++i;
}
break;
}
case MusicPlayer::SHUFFLE_INTELLIGENT:
{
int RatingWeight = 2;
int PlayCountWeight = 2;
int LastPlayWeight = 2;
int RandomWeight = 2;
m_parent->FillIntelliWeights(RatingWeight, PlayCountWeight,
LastPlayWeight, RandomWeight);
// compute max/min playcount,lastplay for this playlist
int playcountMin = 0;
int playcountMax = 0;
double lastplayMin = 0.0;
double lastplayMax = 0.0;
uint idx = 0;
SongList::const_iterator it = m_songs.begin();
for (; it != m_songs.end(); ++it, ++idx)
{
if (!(*it)->isCDTrack())
{
MusicMetadata *mdata = (*it);
if (0 == idx)
{
// first song
playcountMin = playcountMax = mdata->PlayCount();
lastplayMin = lastplayMax = mdata->LastPlay().toTime_t();
}
else
{
if (mdata->PlayCount() < playcountMin)
playcountMin = mdata->PlayCount();
else if (mdata->PlayCount() > playcountMax)
playcountMax = mdata->PlayCount();
if (mdata->LastPlay().toTime_t() < lastplayMin)
lastplayMin = mdata->LastPlay().toTime_t();
else if (mdata->LastPlay().toTime_t() > lastplayMax)
lastplayMax = mdata->LastPlay().toTime_t();
}
}
}
// next we compute all the weights
std::map<int,double> weights;
std::map<int,int> ratings;
std::map<int,int> ratingCounts;
int TotalWeight = RatingWeight + PlayCountWeight + LastPlayWeight;
for (int trackItI = 0; trackItI < m_songs.size(); ++trackItI)
{
MusicMetadata *mdata = m_songs[trackItI];
if (!mdata->isCDTrack())
{
int rating = mdata->Rating();
int playcount = mdata->PlayCount();
double lastplaydbl = mdata->LastPlay().toTime_t();
double ratingValue = (double)(rating) / 10;
double playcountValue, lastplayValue;
if (playcountMax == playcountMin)
playcountValue = 0;
else
playcountValue = ((playcountMin - (double)playcount) / (playcountMax - playcountMin) + 1);
if (lastplayMax == lastplayMin)
lastplayValue = 0;
else
lastplayValue = ((lastplayMin - lastplaydbl) / (lastplayMax - lastplayMin) + 1);
double weight = (RatingWeight * ratingValue +
PlayCountWeight * playcountValue +
LastPlayWeight * lastplayValue) / TotalWeight;
weights[mdata->ID()] = weight;
//.........这里部分代码省略.........