本文整理汇总了C++中CFileItem::GetArt方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItem::GetArt方法的具体用法?C++ CFileItem::GetArt怎么用?C++ CFileItem::GetArt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItem
的用法示例。
在下文中一共展示了CFileItem::GetArt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChooseArtType
string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string, string> ¤tArt)
{
// prompt for choice
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog || !videoItem.HasVideoInfoTag())
return "";
CFileItemList items;
dialog->SetHeading(13511);
dialog->Reset();
dialog->SetUseDetails(true);
dialog->EnableButton(true, 13516);
CVideoDatabase db;
db.Open();
vector<string> artTypes = CVideoThumbLoader::GetArtTypes(videoItem.GetVideoInfoTag()->m_type);
// add in any stored art for this item that is non-empty.
db.GetArtForItem(videoItem.GetVideoInfoTag()->m_iDbId, videoItem.GetVideoInfoTag()->m_type, currentArt);
for (CGUIListItem::ArtMap::iterator i = currentArt.begin(); i != currentArt.end(); ++i)
{
if (!i->second.empty() && find(artTypes.begin(), artTypes.end(), i->first) == artTypes.end())
artTypes.push_back(i->first);
}
// add any art types that exist for other media items of the same type
vector<string> dbArtTypes;
db.GetArtTypes(videoItem.GetVideoInfoTag()->m_type, dbArtTypes);
for (vector<string>::const_iterator it = dbArtTypes.begin(); it != dbArtTypes.end(); it++)
{
if (find(artTypes.begin(), artTypes.end(), *it) == artTypes.end())
artTypes.push_back(*it);
}
for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
{
string type = *i;
CFileItemPtr item(new CFileItem(type, "false"));
item->SetLabel(type);
if (videoItem.HasArt(type))
item->SetArt("thumb", videoItem.GetArt(type));
items.Add(item);
}
dialog->SetItems(&items);
dialog->DoModal();
if (dialog->IsButtonPressed())
{
// Get the new artwork name
CStdString strArtworkName;
if (!CGUIKeyboardFactory::ShowAndGetInput(strArtworkName, g_localizeStrings.Get(13516), false))
return "";
return strArtworkName;
}
return dialog->GetSelectedItem()->GetLabel();
}
示例2: FillLibraryArt
bool CVideoThumbLoader::FillLibraryArt(CFileItem &item)
{
CVideoInfoTag &tag = *item.GetVideoInfoTag();
if (tag.m_iDbId > -1 && !tag.m_type.empty())
{
std::map<std::string, std::string> artwork;
m_videoDatabase->Open();
if (m_videoDatabase->GetArtForItem(tag.m_iDbId, tag.m_type, artwork))
SetArt(item, artwork);
else if (tag.m_type == "actor" && !tag.m_artist.empty())
{ // we retrieve music video art from the music database (no backward compat)
CMusicDatabase database;
database.Open();
int idArtist = database.GetArtistByName(item.GetLabel());
if (database.GetArtForItem(idArtist, MediaTypeArtist, artwork))
item.SetArt(artwork);
}
else if (tag.m_type == MediaTypeAlbum)
{ // we retrieve music video art from the music database (no backward compat)
CMusicDatabase database;
database.Open();
int idAlbum = database.GetAlbumByName(item.GetLabel(), tag.m_artist);
if (database.GetArtForItem(idAlbum, MediaTypeAlbum, artwork))
item.SetArt(artwork);
}
if (tag.m_type == MediaTypeEpisode || tag.m_type == MediaTypeSeason)
{
// For episodes and seasons, we want to set fanart for that of the show
if (!item.HasArt("tvshow.fanart") && tag.m_iIdShow >= 0)
{
const ArtMap& artmap = GetArtFromCache(MediaTypeTvShow, tag.m_iIdShow);
if (!artmap.empty())
{
item.AppendArt(artmap, MediaTypeTvShow);
item.SetArtFallback("fanart", "tvshow.fanart");
item.SetArtFallback("tvshow.thumb", "tvshow.poster");
}
}
if (tag.m_type == MediaTypeEpisode && !item.HasArt("season.poster") && tag.m_iSeason > -1)
{
const ArtMap& artmap = GetArtFromCache(MediaTypeSeason, tag.m_iIdSeason);
if (!artmap.empty())
item.AppendArt(artmap, MediaTypeSeason);
}
}
else if (tag.m_type == MediaTypeMovie && tag.m_set.id >= 0 && !item.HasArt("set.fanart"))
{
const ArtMap& artmap = GetArtFromCache(MediaTypeVideoCollection, tag.m_set.id);
if (!artmap.empty())
item.AppendArt(artmap, MediaTypeVideoCollection);
}
m_videoDatabase->Close();
}
return !item.GetArt().empty();
}
示例3: FillLibraryArt
bool CVideoThumbLoader::FillLibraryArt(CFileItem &item)
{
CVideoInfoTag &tag = *item.GetVideoInfoTag();
if (tag.m_iDbId > -1 && !tag.m_type.IsEmpty())
{
map<string, string> artwork;
m_database->Open();
if (m_database->GetArtForItem(tag.m_iDbId, tag.m_type, artwork))
item.SetArt(artwork);
else if (tag.m_type == "artist")
{ // we retrieve music video art from the music database (no backward compat)
CMusicDatabase database;
database.Open();
int idArtist = database.GetArtistByName(item.GetLabel());
if (database.GetArtForItem(idArtist, "artist", artwork))
item.SetArt(artwork);
}
else if (tag.m_type == "album")
{ // we retrieve music video art from the music database (no backward compat)
CMusicDatabase database;
database.Open();
int idAlbum = database.GetAlbumByName(item.GetLabel(), tag.m_artist);
if (database.GetArtForItem(idAlbum, "album", artwork))
item.SetArt(artwork);
}
// For episodes and seasons, we want to set fanart for that of the show
if (!item.HasArt("fanart") && tag.m_iIdShow >= 0)
{
ArtCache::const_iterator i = m_showArt.find(tag.m_iIdShow);
if (i != m_showArt.end())
item.AppendArt(i->second);
else
{
map<string, string> showArt, cacheArt;
if (m_database->GetArtForItem(tag.m_iIdShow, "tvshow", showArt))
{
for (CGUIListItem::ArtMap::iterator i = showArt.begin(); i != showArt.end(); ++i)
{
if (i->first == "fanart")
cacheArt.insert(*i);
else
cacheArt.insert(make_pair("tvshow." + i->first, i->second));
}
item.AppendArt(cacheArt);
}
m_showArt.insert(make_pair(tag.m_iIdShow, cacheArt));
}
}
m_database->Close();
}
return !item.GetArt().empty();
}
示例4: FillLibraryArt
bool CMusicThumbLoader::FillLibraryArt(CFileItem &item)
{
CMusicInfoTag &tag = *item.GetMusicInfoTag();
if (tag.GetDatabaseId() > -1 && !tag.GetType().empty())
{
m_musicDatabase->Open();
map<string, string> artwork;
if (m_musicDatabase->GetArtForItem(tag.GetDatabaseId(), tag.GetType(), artwork))
item.SetArt(artwork);
else if (tag.GetType() == "song")
{ // no art for the song, try the album
ArtCache::const_iterator i = m_albumArt.find(tag.GetAlbumId());
if (i == m_albumArt.end())
{
m_musicDatabase->GetArtForItem(tag.GetAlbumId(), "album", artwork);
i = m_albumArt.insert(make_pair(tag.GetAlbumId(), artwork)).first;
}
if (i != m_albumArt.end())
{
item.AppendArt(i->second, "album");
for (map<string, string>::const_iterator j = i->second.begin(); j != i->second.end(); ++j)
item.SetArtFallback(j->first, "album." + j->first);
}
}
if (tag.GetType() == "song" || tag.GetType() == "album")
{ // fanart from the artist
string fanart = m_musicDatabase->GetArtistArtForItem(tag.GetDatabaseId(), tag.GetType(), "fanart");
if (!fanart.empty())
{
item.SetArt("artist.fanart", fanart);
item.SetArtFallback("fanart", "artist.fanart");
}
else if (tag.GetType() == "song")
{
// If no artist fanart, try for album artist fanart
fanart = m_musicDatabase->GetArtistArtForItem(tag.GetAlbumId(), "album", "fanart");
if (!fanart.empty())
{
item.SetArt("albumartist.fanart", fanart);
item.SetArtFallback("fanart", "albumartist.fanart");
}
}
}
m_musicDatabase->Close();
}
return !item.GetArt().empty();
}
示例5: FillLibraryArt
bool CVideoThumbLoader::FillLibraryArt(CFileItem &item)
{
CVideoInfoTag &tag = *item.GetVideoInfoTag();
if (tag.m_iDbId > -1 && !tag.m_type.empty())
{
map<string, string> artwork;
m_videoDatabase->Open();
if (m_videoDatabase->GetArtForItem(tag.m_iDbId, tag.m_type, artwork))
SetArt(item, artwork);
else if (tag.m_type == MediaTypeArtist)
{ // we retrieve music video art from the music database (no backward compat)
CMusicDatabase database;
database.Open();
int idArtist = database.GetArtistByName(item.GetLabel());
if (database.GetArtForItem(idArtist, MediaTypeArtist, artwork))
item.SetArt(artwork);
}
else if (tag.m_type == MediaTypeAlbum)
{ // we retrieve music video art from the music database (no backward compat)
CMusicDatabase database;
database.Open();
int idAlbum = database.GetAlbumByName(item.GetLabel(), tag.m_artist);
if (database.GetArtForItem(idAlbum, MediaTypeAlbum, artwork))
item.SetArt(artwork);
}
// For episodes and seasons, we want to set fanart for that of the show
if (!item.HasArt("fanart") && tag.m_iIdShow >= 0)
{
ArtCache::const_iterator i = m_showArt.find(tag.m_iIdShow);
if (i == m_showArt.end())
{
map<string, string> showArt;
m_videoDatabase->GetArtForItem(tag.m_iIdShow, MediaTypeTvShow, showArt);
i = m_showArt.insert(make_pair(tag.m_iIdShow, showArt)).first;
}
if (i != m_showArt.end())
{
item.AppendArt(i->second, "tvshow");
item.SetArtFallback("fanart", "tvshow.fanart");
item.SetArtFallback("tvshow.thumb", "tvshow.poster");
}
}
m_videoDatabase->Close();
}
return !item.GetArt().empty();
}
示例6: ChooseArtType
string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string, string> ¤tArt)
{
// prompt for choice
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog || !videoItem.HasVideoInfoTag())
return "";
CFileItemList items;
dialog->SetHeading(13511);
dialog->Reset();
dialog->SetUseDetails(true);
CVideoDatabase db;
db.Open();
vector<string> artTypes = CVideoThumbLoader::GetArtTypes(videoItem.GetVideoInfoTag()->m_type);
// add in any stored art for this item that is non-empty.
db.GetArtForItem(videoItem.GetVideoInfoTag()->m_iDbId, videoItem.GetVideoInfoTag()->m_type, currentArt);
for (CGUIListItem::ArtMap::iterator i = currentArt.begin(); i != currentArt.end(); ++i)
{
if (!i->second.empty() && find(artTypes.begin(), artTypes.end(), i->first) == artTypes.end())
artTypes.push_back(i->first);
}
for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
{
string type = *i;
CFileItemPtr item(new CFileItem(type, "false"));
item->SetLabel(type);
if (videoItem.HasArt(type))
item->SetArt("thumb", videoItem.GetArt(type));
items.Add(item);
}
dialog->SetItems(&items);
dialog->DoModal();
return dialog->GetSelectedItem()->GetLabel();
}
示例7: AddOrRemove
bool CFavouritesService::AddOrRemove(const CFileItem& item, int contextWindow)
{
auto favUrl = GetFavouritesUrl(item, contextWindow);
{
CSingleLock lock(m_criticalSection);
CFileItemPtr match = m_favourites.Get(favUrl);
if (match)
{ // remove the item
m_favourites.Remove(match.get());
}
else
{ // create our new favourite item
const CFileItemPtr favourite(std::make_shared<CFileItem>(item.GetLabel()));
if (item.GetLabel().empty())
favourite->SetLabel(CUtil::GetTitleFromPath(item.GetPath(), item.m_bIsFolder));
favourite->SetArt("thumb", item.GetArt("thumb"));
favourite->SetPath(favUrl);
m_favourites.Add(favourite);
}
Persist();
}
OnUpdated();
return true;
}
示例8: GetSongs
//.........这里部分代码省略.........
musicUrl.AddOption("albumid", static_cast<int>(filter["albumid"].asInteger()));
else if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
else if (filter.isObject())
{
std::string xsp;
if (!GetXspFiltering("songs", filter, xsp))
return InvalidParams;
musicUrl.AddOption("xsp", xsp);
}
SortDescription sorting;
ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd);
if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes))
return InvalidParams;
int total;
std::set<std::string> fields;
if (parameterObject.isMember("properties") && parameterObject["properties"].isArray())
{
for (CVariant::const_iterator_array field = parameterObject["properties"].begin_array();
field != parameterObject["properties"].end_array(); field++)
fields.insert(field->asString());
}
if (!musicdatabase.GetSongsByWhereJSON(fields, musicUrl.ToString(), result, total, sorting))
return InternalError;
if (!result.isNull())
{
bool bFetchArt = fields.find("art") != fields.end();
bool bFetchFanart = fields.find("fanart") != fields.end();
bool bFetchThumb = fields.find("thumbnail") != fields.end();
if (bFetchArt || bFetchFanart || bFetchThumb)
{
CThumbLoader* thumbLoader = new CMusicThumbLoader();
thumbLoader->OnLoaderStart();
std::set<std::string> artfields;
if (bFetchArt)
artfields.insert("art");
if (bFetchFanart)
artfields.insert("fanart");
if (bFetchThumb)
artfields.insert("thumbnail");
for (unsigned int index = 0; index < result["songs"].size(); index++)
{
CFileItem item;
// Only needs song and album id (if we have it) set to get art
// Getting art is quicker if "albumid" has been fetched
item.GetMusicInfoTag()->SetDatabaseId(result["songs"][index]["songid"].asInteger(), MediaTypeSong);
if (result["songs"][index].isMember("albumid"))
item.GetMusicInfoTag()->SetAlbumId(result["songs"][index]["albumid"].asInteger());
else
item.GetMusicInfoTag()->SetAlbumId(-1);
// Could use FillDetails, but it does unnecessary serialization of empty MusiInfoTag
// CFileItemPtr itemptr(new CFileItem(item));
// FillDetails(item.GetMusicInfoTag(), itemptr, artfields, result["songs"][index], thumbLoader);
thumbLoader->FillLibraryArt(item);
if (bFetchThumb)
{
if (item.HasArt("thumb"))
result["songs"][index]["thumbnail"] = CTextureUtils::GetWrappedImageURL(item.GetArt("thumb"));
else
result["songs"][index]["thumbnail"] = "";
}
if (bFetchFanart)
{
if (item.HasArt("fanart"))
result["songs"][index]["fanart"] = CTextureUtils::GetWrappedImageURL(item.GetArt("fanart"));
else
result["songs"][index]["fanart"] = "";
}
if (bFetchArt)
{
CGUIListItem::ArtMap artMap = item.GetArt();
CVariant artObj(CVariant::VariantTypeObject);
for (CGUIListItem::ArtMap::const_iterator artIt = artMap.begin(); artIt != artMap.end(); ++artIt)
{
if (!artIt->second.empty())
artObj[artIt->first] = CTextureUtils::GetWrappedImageURL(artIt->second);
}
result["songs"][index]["art"] = artObj;
}
}
delete thumbLoader;
}
}
int start, end;
HandleLimits(parameterObject, result, total, start, end);
return OK;
}