/*
* Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
+ * http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "playlists/PlayList.h"
#include "utils/TimeUtils.h"
#include "utils/log.h"
+#include "utils/StringUtils.h"
#include "Application.h"
#include "interfaces/AnnouncementManager.h"
{
m_bIsVideo = false;
m_bEnabled = false;
- m_strCurrentFilterMusic.Empty();
- m_strCurrentFilterVideo.Empty();
+ m_strCurrentFilterMusic.clear();
+ m_strCurrentFilterVideo.clear();
ClearState();
}
bool playlistLoaded;
m_bIsVideo = context == PARTYMODECONTEXT_VIDEO;
- if (!strXspPath.IsEmpty()) //if a path to a smartplaylist is supplied use it
+ if (!strXspPath.empty()) //if a path to a smartplaylist is supplied use it
partyModePath = strXspPath;
else if (m_bIsVideo)
partyModePath = CProfilesManager::Get().GetUserDataItem("PartyMode-Video.xsp");
}
else
{
- m_strCurrentFilterMusic.Empty();
- m_strCurrentFilterVideo.Empty();
+ m_strCurrentFilterMusic.clear();
+ m_strCurrentFilterVideo.clear();
m_type = m_bIsVideo ? "musicvideos" : "songs";
}
for (vector< pair<int,int> >::iterator it = chosenSongIDs.begin(); it != chosenSongIDs.end(); it++)
{
- CStdString song;
- song.Format("%i,", it->second);
+ CStdString song = StringUtils::Format("%i,", it->second);
if (it->first == 1)
sqlWhereMusic += song;
if (it->first == 2)
sqlWhereMusic[sqlWhereMusic.size() - 1] = ')'; // replace the last comma with closing bracket
CMusicDatabase database;
database.Open();
- database.GetSongsByWhere("musicdb://4/", sqlWhereMusic, items);
+ database.GetSongsByWhere("musicdb://songs/", sqlWhereMusic, items);
}
if (sqlWhereVideo.size() > 19)
{
sqlWhereVideo[sqlWhereVideo.size() - 1] = ')'; // replace the last comma with closing bracket
CVideoDatabase database;
database.Open();
- database.GetMusicVideosByWhere("videodb://3/2/", sqlWhereVideo, items);
+ database.GetMusicVideosByWhere("videodb://musicvideos/titles/", sqlWhereVideo, items);
}
m_history = chosenSongIDs;
pair<CStdString,CStdString> CPartyModeManager::GetWhereClauseWithHistory() const
{
- CStdString historyWhereMusic;
- CStdString historyWhereVideo;
// now add this on to the normal where clause
- if (m_history.size())
+ std::vector<std::string> historyItemsMusic;
+ std::vector<std::string> historyItemsVideo;
+ for (unsigned int i = 0; i < m_history.size(); i++)
{
- if (m_strCurrentFilterMusic.IsEmpty())
- historyWhereMusic = "songview.idSong not in (";
- else
- historyWhereMusic = m_strCurrentFilterMusic + " and songview.idSong not in (";
- if (m_strCurrentFilterVideo.IsEmpty())
- historyWhereVideo = "idMVideo not in (";
- else
- historyWhereVideo = m_strCurrentFilterVideo + " and idMVideo not in (";
+ std::string number = StringUtils::Format("%i", m_history[i].second);
+ if (m_history[i].first == 1)
+ historyItemsMusic.push_back(number);
+ if (m_history[i].first == 2)
+ historyItemsVideo.push_back(number);
+ }
- for (unsigned int i = 0; i < m_history.size(); i++)
- {
- CStdString number;
- number.Format("%i,", m_history[i].second);
- if (m_history[i].first == 1)
- historyWhereMusic += number;
- if (m_history[i].first == 2)
- historyWhereVideo += number;
- }
- historyWhereMusic.TrimRight(",");
- historyWhereMusic += ")";
- historyWhereVideo.TrimRight(",");
- historyWhereVideo += ")";
+ std::string historyWhereMusic;
+ if (!historyItemsMusic.empty())
+ {
+ if (!m_strCurrentFilterMusic.empty())
+ historyWhereMusic = m_strCurrentFilterMusic + " and ";
+ historyWhereMusic += "songview.idSong not in (" + StringUtils::Join(historyItemsMusic, ", ") + ")";
}
- return make_pair(historyWhereMusic,historyWhereVideo);
+
+ std::string historyWhereVideo;
+ if (!historyItemsVideo.empty())
+ {
+ if (!m_strCurrentFilterVideo.empty())
+ historyWhereVideo = m_strCurrentFilterVideo + " and ";
+ historyWhereVideo += "idMVideo not in (" + StringUtils::Join(historyItemsVideo, ", ") + ")";
+ }
+
+ return make_pair(historyWhereMusic, historyWhereVideo);
}
void CPartyModeManager::AddToHistory(int type, int songID)
void CPartyModeManager::Announce()
{
- if (g_application.IsPlaying())
+ if (g_application.m_pPlayer->IsPlaying())
{
CVariant data;