本文整理汇总了C++中CFileItemPtr::GetArt方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemPtr::GetArt方法的具体用法?C++ CFileItemPtr::GetArt怎么用?C++ CFileItemPtr::GetArt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemPtr
的用法示例。
在下文中一共展示了CFileItemPtr::GetArt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
bool CFavouritesDirectory::Save(const CFileItemList &items)
{
std::string favourites;
CXBMCTinyXML doc;
TiXmlElement xmlRootElement("favourites");
TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement);
if (!rootNode) return false;
for (int i = 0; i < items.Size(); i++)
{
const CFileItemPtr item = items[i];
TiXmlElement favNode("favourite");
favNode.SetAttribute("name", item->GetLabel().c_str());
if (item->HasArt("thumb"))
favNode.SetAttribute("thumb", item->GetArt("thumb").c_str());
TiXmlText execute(item->GetPath());
favNode.InsertEndChild(execute);
rootNode->InsertEndChild(favNode);
}
favourites = URIUtils::AddFileToFolder(CProfilesManager::GetInstance().GetProfileUserDataFolder(), "favourites.xml");
bool bRet = doc.SaveFile(favourites);
if (bRet)
ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::GUI, "xbmc", "OnFavouritesUpdated");
return bRet;
}
示例2: OnSetThumb
void CGUIDialogFavourites::OnSetThumb(int item)
{
if (item < 0 || item >= m_favourites->Size())
return;
CFileItemPtr pItem = (*m_favourites)[item];
CFileItemList items;
// Current
if (pItem->HasArt("thumb"))
{
CFileItemPtr current(new CFileItem("thumb://Current", false));
current->SetArt("thumb", pItem->GetArt("thumb"));
current->SetLabel(g_localizeStrings.Get(20016));
items.Add(current);
}
// None
CFileItemPtr none(new CFileItem("thumb://None", false));
none->SetIconImage(pItem->GetIconImage());
none->SetLabel(g_localizeStrings.Get(20018));
items.Add(none);
CStdString thumb;
VECSOURCES sources;
g_mediaManager.GetLocalDrives(sources);
if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(1030), thumb))
return;
(*m_favourites)[item]->SetArt("thumb", thumb);
CFavourites::Save(*m_favourites);
UpdateList();
}
示例3: ChooseAndSetNewThumbnail
bool CGUIDialogFavourites::ChooseAndSetNewThumbnail(const CFileItemPtr &item)
{
CFileItemList prefilledItems;
if (item->HasArt("thumb"))
{
const CFileItemPtr current(std::make_shared<CFileItem>("thumb://Current", false));
current->SetArt("thumb", item->GetArt("thumb"));
current->SetLabel(g_localizeStrings.Get(20016)); // Current thumb
prefilledItems.Add(current);
}
const CFileItemPtr none(std::make_shared<CFileItem>("thumb://None", false));
none->SetIconImage(item->GetIconImage());
none->SetLabel(g_localizeStrings.Get(20018)); // No thumb
prefilledItems.Add(none);
std::string thumb;
VECSOURCES sources;
g_mediaManager.GetLocalDrives(sources);
if (CGUIDialogFileBrowser::ShowAndGetImage(prefilledItems, sources, g_localizeStrings.Get(1030), thumb)) // Browse for image
{
item->SetArt("thumb", thumb);
return true;
}
return false;
}
示例4: OnClickButtonChannelLogo
bool CGUIDialogPVRChannelManager::OnClickButtonChannelLogo(CGUIMessage &message)
{
CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
if (!pItem)
return false;
if (g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
return false;
else if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
// setup our thumb list
CFileItemList items;
// add the current thumb, if available
if (!pItem->GetProperty("Icon").asString().empty())
{
CFileItemPtr current(new CFileItem("thumb://Current", false));
current->SetArt("thumb", pItem->GetPVRChannelInfoTag()->IconPath());
current->SetLabel(g_localizeStrings.Get(20016));
items.Add(current);
}
else if (pItem->HasArt("thumb"))
{ // already have a thumb that the share doesn't know about - must be a local one, so we mayaswell reuse it.
CFileItemPtr current(new CFileItem("thumb://Current", false));
current->SetArt("thumb", pItem->GetArt("thumb"));
current->SetLabel(g_localizeStrings.Get(20016));
items.Add(current);
}
// and add a "no thumb" entry as well
CFileItemPtr nothumb(new CFileItem("thumb://None", false));
nothumb->SetIconImage(pItem->GetIconImage());
nothumb->SetLabel(g_localizeStrings.Get(20018));
items.Add(nothumb);
CStdString strThumb;
VECSOURCES shares;
if (g_guiSettings.GetString("pvrmenu.iconpath") != "")
{
CMediaSource share1;
share1.strPath = g_guiSettings.GetString("pvrmenu.iconpath");
share1.strName = g_localizeStrings.Get(19018);
shares.push_back(share1);
}
g_mediaManager.GetLocalDrives(shares);
if (!CGUIDialogFileBrowser::ShowAndGetImage(items, shares, g_localizeStrings.Get(1030), strThumb))
return false;
if (strThumb == "thumb://Current")
return true;
if (strThumb == "thumb://None")
strThumb = "";
pItem->SetProperty("Icon", strThumb);
pItem->SetProperty("Changed", true);
m_bContainsChanges = true;
return true;
}
示例5: OnLoaderFinish
void CMusicInfoLoader::OnLoaderFinish()
{
// cleanup last loaded songs from database
m_songsMap.Clear();
// cleanup cache loaded from HD
m_mapFileItems->Clear();
if (!m_bStop)
{ // check for art
VECSONGS songs;
songs.reserve(m_pVecItems->Size());
for (int i = 0; i < m_pVecItems->Size(); ++i)
{
CFileItemPtr pItem = m_pVecItems->Get(i);
if (pItem->m_bIsFolder || pItem->IsPlayList() || pItem->IsNFO() || pItem->IsInternetStream())
continue;
if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded())
{
CSong song(*pItem->GetMusicInfoTag());
song.strThumb = pItem->GetArt("thumb");
song.idSong = i; // for the lookup below
songs.push_back(song);
}
}
VECALBUMS albums;
CMusicInfoScanner::CategoriseAlbums(songs, albums);
CMusicInfoScanner::FindArtForAlbums(albums, m_pVecItems->GetPath());
for (VECALBUMS::iterator i = albums.begin(); i != albums.end(); ++i)
{
string albumArt = i->art["thumb"];
for (VECSONGS::iterator j = i->songs.begin(); j != i->songs.end(); ++j)
{
if (!j->strThumb.empty())
m_pVecItems->Get(j->idSong)->SetArt("thumb", j->strThumb);
else
m_pVecItems->Get(j->idSong)->SetArt("thumb", albumArt);
}
}
}
// Save loaded items to HD
if (!m_strCacheFileName.IsEmpty())
SaveCache(m_strCacheFileName, *m_pVecItems);
else if (!m_bStop && (m_databaseHits > 1 || m_tagReads > 0))
m_pVecItems->Save();
m_musicDatabase.Close();
}
示例6: GetPlaylistInfo
bool CMusicGUIInfo::GetPlaylistInfo(std::string& value, const CGUIInfo &info) const
{
PLAYLIST::CPlayList& playlist = CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST_MUSIC);
if (playlist.size() < 1)
return false;
int index = info.GetData2();
if (info.GetData1() == 1)
{ // relative index (requires current playlist is PLAYLIST_MUSIC)
if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST_MUSIC)
return false;
index = CServiceBroker::GetPlaylistPlayer().GetNextSong(index);
}
if (index < 0 || index >= playlist.size())
return false;
const CFileItemPtr playlistItem = playlist[index];
if (!playlistItem->GetMusicInfoTag()->Loaded())
{
playlistItem->LoadMusicTag();
playlistItem->GetMusicInfoTag()->SetLoaded();
}
// try to set a thumbnail
if (!playlistItem->HasArt("thumb"))
{
CMusicThumbLoader loader;
loader.LoadItem(playlistItem.get());
// still no thumb? then just the set the default cover
if (!playlistItem->HasArt("thumb"))
playlistItem->SetArt("thumb", "DefaultAlbumCover.png");
}
if (info.m_info == MUSICPLAYER_PLAYLISTPOS)
{
value = StringUtils::Format("%i", index + 1);
return true;
}
else if (info.m_info == MUSICPLAYER_COVER)
{
value = playlistItem->GetArt("thumb");
return true;
}
return GetLabel(value, playlistItem.get(), 0, CGUIInfo(info.m_info), nullptr);
}
示例7: LoadItemCached
bool CPictureInfoLoader::LoadItemCached(CFileItem* pItem)
{
if (!pItem->IsPicture() || pItem->IsZIP() || pItem->IsRAR() || pItem->IsCBR() || pItem->IsCBZ() || pItem->IsInternetStream() || pItem->IsVideo())
return false;
if (pItem->HasPictureInfoTag())
return true;
// Check the cached item
CFileItemPtr mapItem = (*m_mapFileItems)[pItem->GetPath()];
if (mapItem && mapItem->m_dateTime==pItem->m_dateTime && mapItem->HasPictureInfoTag())
{ // Query map if we previously cached the file on HD
*pItem->GetPictureInfoTag() = *mapItem->GetPictureInfoTag();
pItem->SetArt("thumb", mapItem->GetArt("thumb"));
return true;
}
return true;
}
示例8: LoadItemLookup
bool CMusicInfoLoader::LoadItemLookup(CFileItem* pItem)
{
if (m_pProgressCallback && !pItem->m_bIsFolder)
m_pProgressCallback->SetProgressAdvance();
if (pItem->m_bIsFolder || pItem->IsPlayList() || pItem->IsNFO() || pItem->IsInternetStream())
return false;
if (!pItem->HasMusicInfoTag() || !pItem->GetMusicInfoTag()->Loaded())
{
// first check the cached item
CFileItemPtr mapItem = (*m_mapFileItems)[pItem->GetPath()];
if (mapItem && mapItem->m_dateTime==pItem->m_dateTime && mapItem->HasMusicInfoTag() && mapItem->GetMusicInfoTag()->Loaded())
{ // Query map if we previously cached the file on HD
*pItem->GetMusicInfoTag() = *mapItem->GetMusicInfoTag();
if (mapItem->HasArt("thumb"))
pItem->SetArt("thumb", mapItem->GetArt("thumb"));
}
else
{
std::string strPath = URIUtils::GetDirectory(pItem->GetPath());
URIUtils::AddSlashAtEnd(strPath);
if (strPath!=m_strPrevPath)
{
// The item is from another directory as the last one,
// query the database for the new directory...
m_musicDatabase.GetSongsByPath(strPath, m_songsMap);
m_databaseHits++;
}
MAPSONGS::iterator it = m_songsMap.find(pItem->GetPath());
if (it != m_songsMap.end())
{ // Have we loaded this item from database before
pItem->GetMusicInfoTag()->SetSong(it->second);
pItem->GetMusicInfoTag()->SetCueSheet(m_musicDatabase.LoadCuesheet(it->second.strFileName));
if (!it->second.strThumb.empty())
pItem->SetArt("thumb", it->second.strThumb);
}
else if (pItem->IsMusicDb())
{ // a music db item that doesn't have tag loaded - grab details from the database
XFILE::MUSICDATABASEDIRECTORY::CQueryParams param;
XFILE::MUSICDATABASEDIRECTORY::CDirectoryNode::GetDatabaseInfo(pItem->GetPath(),param);
CSong song;
if (m_musicDatabase.GetSong(param.GetSongId(), song))
{
pItem->GetMusicInfoTag()->SetSong(song);
if (!song.strThumb.empty())
pItem->SetArt("thumb", song.strThumb);
}
}
else if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MUSICFILES_USETAGS) || pItem->IsCDDA())
{ // Nothing found, load tag from file,
// always try to load cddb info
// get correct tag parser
std::unique_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(*pItem));
if (NULL != pLoader.get())
// get tag
pLoader->Load(pItem->GetPath(), *pItem->GetMusicInfoTag());
m_tagReads++;
}
m_strPrevPath = strPath;
}
}
return true;
}
示例9: UpdateVideo
bool CRecentlyAddedJob::UpdateVideo()
{
CGUIWindow* home = g_windowManager.GetWindow(WINDOW_HOME);
if ( home == NULL )
return false;
CLog::Log(LOGDEBUG, "CRecentlyAddedJob::UpdateVideos() - Running RecentlyAdded home screen update");
int i = 0;
CFileItemList items;
CVideoDatabase videodatabase;
CVideoThumbLoader loader;
loader.Initialize();
videodatabase.Open();
if (videodatabase.GetRecentlyAddedMoviesNav("videodb://4/", items, NUM_ITEMS))
{
for (; i < items.Size(); ++i)
{
CFileItemPtr item = items.Get(i);
CStdString value;
CStdString strRating;
value.Format("%i", i + 1);
strRating.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
home->SetProperty("LatestMovie." + value + ".Title" , item->GetLabel());
home->SetProperty("LatestMovie." + value + ".Rating" , strRating);
home->SetProperty("LatestMovie." + value + ".Year" , item->GetVideoInfoTag()->m_iYear);
home->SetProperty("LatestMovie." + value + ".Plot" , item->GetVideoInfoTag()->m_strPlot);
home->SetProperty("LatestMovie." + value + ".RunningTime" , item->GetVideoInfoTag()->GetDuration() / 60);
home->SetProperty("LatestMovie." + value + ".Path" , item->GetVideoInfoTag()->m_strFileNameAndPath);
home->SetProperty("LatestMovie." + value + ".Trailer" , item->GetVideoInfoTag()->m_strTrailer);
if (!item->HasArt("thumb"))
loader.LoadItem(item.get());
home->SetProperty("LatestMovie." + value + ".Thumb" , item->GetArt("thumb"));
home->SetProperty("LatestMovie." + value + ".Fanart" , item->GetArt("fanart"));
}
}
for (; i < NUM_ITEMS; ++i)
{
CStdString value;
value.Format("%i", i + 1);
home->SetProperty("LatestMovie." + value + ".Title" , "");
home->SetProperty("LatestMovie." + value + ".Thumb" , "");
home->SetProperty("LatestMovie." + value + ".Rating" , "");
home->SetProperty("LatestMovie." + value + ".Year" , "");
home->SetProperty("LatestMovie." + value + ".Plot" , "");
home->SetProperty("LatestMovie." + value + ".RunningTime" , "");
home->SetProperty("LatestMovie." + value + ".Path" , "");
home->SetProperty("LatestMovie." + value + ".Trailer" , "");
home->SetProperty("LatestMovie." + value + ".Fanart" , "");
}
i = 0;
CFileItemList TVShowItems;
if (videodatabase.GetRecentlyAddedEpisodesNav("videodb://5/", TVShowItems, NUM_ITEMS))
{
for (; i < TVShowItems.Size(); ++i)
{
CFileItemPtr item = TVShowItems.Get(i);
int EpisodeSeason = item->GetVideoInfoTag()->m_iSeason;
int EpisodeNumber = item->GetVideoInfoTag()->m_iEpisode;
CStdString EpisodeNo;
CStdString value;
CStdString strRating;
EpisodeNo.Format("s%02de%02d", EpisodeSeason, EpisodeNumber);
value.Format("%i", i + 1);
strRating.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
CFileItem show(item->GetVideoInfoTag()->m_strShowPath, true);
home->SetProperty("LatestEpisode." + value + ".ShowTitle" , item->GetVideoInfoTag()->m_strShowTitle);
home->SetProperty("LatestEpisode." + value + ".EpisodeTitle" , item->GetVideoInfoTag()->m_strTitle);
home->SetProperty("LatestEpisode." + value + ".Rating" , strRating);
home->SetProperty("LatestEpisode." + value + ".Plot" , item->GetVideoInfoTag()->m_strPlot);
home->SetProperty("LatestEpisode." + value + ".EpisodeNo" , EpisodeNo);
home->SetProperty("LatestEpisode." + value + ".EpisodeSeason" , EpisodeSeason);
home->SetProperty("LatestEpisode." + value + ".EpisodeNumber" , EpisodeNumber);
home->SetProperty("LatestEpisode." + value + ".Path" , item->GetVideoInfoTag()->m_strFileNameAndPath);
if (!item->HasArt("thumb"))
loader.LoadItem(item.get());
std::string seasonThumb;
if (item->GetVideoInfoTag()->m_iIdSeason > 0)
seasonThumb = videodatabase.GetArtForItem(item->GetVideoInfoTag()->m_iIdSeason, "season", "thumb");
home->SetProperty("LatestEpisode." + value + ".Thumb" , item->GetArt("thumb"));
home->SetProperty("LatestEpisode." + value + ".ShowThumb" , item->GetArt("tvshow.thumb"));
home->SetProperty("LatestEpisode." + value + ".SeasonThumb" , seasonThumb);
home->SetProperty("LatestEpisode." + value + ".Fanart" , item->GetArt("fanart"));
}
}
for (; i < NUM_ITEMS; ++i)
{
//.........这里部分代码省略.........
示例10: UpdateMusic
bool CRecentlyAddedJob::UpdateMusic()
{
CGUIWindow* home = g_windowManager.GetWindow(WINDOW_HOME);
if ( home == NULL )
return false;
CLog::Log(LOGDEBUG, "CRecentlyAddedJob::UpdateMusic() - Running RecentlyAdded home screen update");
int i = 0;
CFileItemList musicItems;
CMusicDatabase musicdatabase;
CMusicThumbLoader loader;
loader.Initialize();
musicdatabase.Open();
if (musicdatabase.GetRecentlyAddedAlbumSongs("musicdb://4/", musicItems, NUM_ITEMS))
{
long idAlbum = -1;
CStdString strAlbumThumb;
CStdString strAlbumFanart;
for (; i < musicItems.Size(); ++i)
{
CFileItemPtr item = musicItems.Get(i);
CStdString value;
value.Format("%i", i + 1);
CStdString strRating;
CStdString strAlbum = item->GetMusicInfoTag()->GetAlbum();
CStdString strArtist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
if (idAlbum != item->GetMusicInfoTag()->GetAlbumId())
{
strAlbumThumb.clear();
strAlbumFanart.clear();
idAlbum = item->GetMusicInfoTag()->GetAlbumId();
if (loader.LoadItem(item.get()))
{
strAlbumThumb = item->GetArt("thumb");
strAlbumFanart = item->GetArt("fanart");
}
}
strRating.Format("%c", item->GetMusicInfoTag()->GetRating());
home->SetProperty("LatestSong." + value + ".Title" , item->GetMusicInfoTag()->GetTitle());
home->SetProperty("LatestSong." + value + ".Year" , item->GetMusicInfoTag()->GetYear());
home->SetProperty("LatestSong." + value + ".Artist" , strArtist);
home->SetProperty("LatestSong." + value + ".Album" , strAlbum);
home->SetProperty("LatestSong." + value + ".Rating" , strRating);
home->SetProperty("LatestSong." + value + ".Path" , item->GetMusicInfoTag()->GetURL());
home->SetProperty("LatestSong." + value + ".Thumb" , strAlbumThumb);
home->SetProperty("LatestSong." + value + ".Fanart" , strAlbumFanart);
}
}
for (; i < NUM_ITEMS; ++i)
{
CStdString value;
value.Format("%i", i + 1);
home->SetProperty("LatestSong." + value + ".Title" , "");
home->SetProperty("LatestSong." + value + ".Year" , "");
home->SetProperty("LatestSong." + value + ".Artist" , "");
home->SetProperty("LatestSong." + value + ".Album" , "");
home->SetProperty("LatestSong." + value + ".Rating" , "");
home->SetProperty("LatestSong." + value + ".Path" , "");
home->SetProperty("LatestSong." + value + ".Thumb" , "");
home->SetProperty("LatestSong." + value + ".Fanart" , "");
}
i = 0;
VECALBUMS albums;
if (musicdatabase.GetRecentlyAddedAlbums(albums, NUM_ITEMS))
{
for (; i < (int)albums.size(); ++i)
{
CStdString value;
CStdString strPath;
CStdString strThumb;
CStdString strFanart;
CStdString strDBpath;
CStdString strSQLAlbum;
CAlbum& album=albums[i];
value.Format("%i", i + 1);
strThumb = musicdatabase.GetArtForItem(album.idAlbum, "album", "thumb");
strFanart = musicdatabase.GetArtistArtForItem(album.idAlbum, "album", "fanart");
strDBpath.Format("musicdb://3/%i/", album.idAlbum);
strSQLAlbum.Format("idAlbum=%i", album.idAlbum);
CStdString strArtist = musicdatabase.GetSingleValue("albumview", "strArtists", strSQLAlbum);
home->SetProperty("LatestAlbum." + value + ".Title" , album.strAlbum);
home->SetProperty("LatestAlbum." + value + ".Year" , album.iYear);
home->SetProperty("LatestAlbum." + value + ".Artist" , strArtist);
home->SetProperty("LatestAlbum." + value + ".Rating" , album.iRating);
home->SetProperty("LatestAlbum." + value + ".Path" , strDBpath);
home->SetProperty("LatestAlbum." + value + ".Thumb" , strThumb);
//.........这里部分代码省略.........
示例11: GetField
bool CFileItemHandler::GetField(const std::string &field, const CVariant &info, const CFileItemPtr &item, CVariant &result, bool &fetchedArt, CThumbLoader *thumbLoader /* = NULL */)
{
if (result.isMember(field) && !result[field].empty())
return true;
// overwrite serialized values
if (item)
{
if (field == "mimetype" && item->GetMimeType().empty())
{
item->FillInMimeType(false);
result[field] = item->GetMimeType();
return true;
}
}
// check for serialized values
if (info.isMember(field) && !info[field].isNull())
{
result[field] = info[field];
return true;
}
// check if the field requires special handling
if (item)
{
if (item->IsAlbum())
{
if (field == "albumlabel")
{
result[field] = item->GetProperty("album_label");
return true;
}
if (item->HasProperty("album_" + field + "_array"))
{
result[field] = item->GetProperty("album_" + field + "_array");
return true;
}
if (item->HasProperty("album_" + field))
{
result[field] = item->GetProperty("album_" + field);
return true;
}
}
if (item->HasProperty("artist_" + field + "_array"))
{
result[field] = item->GetProperty("artist_" + field + "_array");
return true;
}
if (item->HasProperty("artist_" + field))
{
result[field] = item->GetProperty("artist_" + field);
return true;
}
if (field == "art")
{
if (thumbLoader != NULL && item->GetArt().size() <= 0 && !fetchedArt &&
((item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > -1) || (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > -1)))
{
thumbLoader->FillLibraryArt(*item);
fetchedArt = true;
}
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] = CTextureCache::GetWrappedImageURL(artIt->second);
}
result["art"] = artObj;
return true;
}
if (field == "thumbnail")
{
if (thumbLoader != NULL && !item->HasArt("thumb") && !fetchedArt &&
((item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > -1) || (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > -1)))
{
thumbLoader->FillLibraryArt(*item);
fetchedArt = true;
}
else if (item->HasPictureInfoTag() && !item->HasArt("thumb"))
item->SetArt("thumb", CTextureCache::GetWrappedThumbURL(item->GetPath()));
if (item->HasArt("thumb"))
result["thumbnail"] = CTextureCache::GetWrappedImageURL(item->GetArt("thumb"));
else
result["thumbnail"] = "";
return true;
}
if (field == "fanart")
{
if (thumbLoader != NULL && !item->HasArt("fanart") && !fetchedArt &&
((item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > -1) || (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > -1)))
//.........这里部分代码省略.........
示例12: OnContextButton
bool CGUIDialogContextMenu::OnContextButton(const std::string &type, const CFileItemPtr& item, CONTEXT_BUTTON button)
{
// buttons that are available on both sources and autosourced items
if (!item) return false;
// the rest of the operations require a valid share
CMediaSource *share = GetShare(type, item.get());
if (!share) return false;
switch (button)
{
case CONTEXT_BUTTON_EDIT_SOURCE:
if (CProfilesManager::GetInstance().IsMasterProfile())
{
if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
}
else if (!g_passwordManager.IsProfileLockUnlocked())
return false;
return CGUIDialogMediaSource::ShowAndEditMediaSource(type, *share);
case CONTEXT_BUTTON_REMOVE_SOURCE:
{
if (CProfilesManager::GetInstance().IsMasterProfile())
{
if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
}
else
{
if (!CProfilesManager::GetInstance().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsMasterLockUnlocked(false))
return false;
if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
return false;
}
// prompt user if they want to really delete the source
if (!CGUIDialogYesNo::ShowAndGetInput(CVariant{751}, CVariant{750}))
return false;
// check default before we delete, as deletion will kill the share object
std::string defaultSource(GetDefaultShareNameByType(type));
if (!defaultSource.empty())
{
if (share->strName == defaultSource)
ClearDefault(type);
}
CMediaSourceSettings::GetInstance().DeleteSource(type, share->strName, share->strPath);
return true;
}
case CONTEXT_BUTTON_SET_DEFAULT:
if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
return false;
else if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
// make share default
SetDefault(type, share->strName);
return true;
case CONTEXT_BUTTON_CLEAR_DEFAULT:
if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
return false;
else if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
// remove share default
ClearDefault(type);
return true;
case CONTEXT_BUTTON_SET_THUMB:
{
if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
return false;
else if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
// setup our thumb list
CFileItemList items;
// add the current thumb, if available
if (!share->m_strThumbnailImage.empty())
{
CFileItemPtr current(new CFileItem("thumb://Current", false));
current->SetArt("thumb", share->m_strThumbnailImage);
current->SetLabel(g_localizeStrings.Get(20016));
items.Add(current);
}
else if (item->HasArt("thumb"))
{ // already have a thumb that the share doesn't know about - must be a local one, so we mayaswell reuse it.
CFileItemPtr current(new CFileItem("thumb://Current", false));
current->SetArt("thumb", item->GetArt("thumb"));
current->SetLabel(g_localizeStrings.Get(20016));
items.Add(current);
}
// see if there's a local thumb for this item
std::string folderThumb = item->GetFolderThumb();
if (XFILE::CFile::Exists(folderThumb))
{
CFileItemPtr local(new CFileItem("thumb://Local", false));
local->SetArt("thumb", folderThumb);
local->SetLabel(g_localizeStrings.Get(20017));
//.........这里部分代码省略.........
示例13: GetFavourites
JSONRPC_STATUS CFavouritesOperations::GetFavourites(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CFileItemList favourites;
CServiceBroker::GetFavouritesService().GetAll(favourites);
std::string type = !parameterObject["type"].isNull() ? parameterObject["type"].asString() : "";
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());
}
for (int i = 0; i < favourites.Size(); i++)
{
CVariant object;
CFileItemPtr item = favourites.Get(i);
std::string function;
std::vector<std::string> parameters;
CUtil::SplitExecFunction(item->GetPath(), function, parameters);
if (parameters.empty())
continue;
object["title"] = item->GetLabel();
if (fields.find("thumbnail") != fields.end())
object["thumbnail"] = item->GetArt("thumb");
if (StringUtils::EqualsNoCase(function, "ActivateWindow"))
{
object["type"] = "window";
if (fields.find("window") != fields.end())
{
if (StringUtils::IsNaturalNumber(parameters[0]))
object["window"] = CWindowTranslator::TranslateWindow(strtol(parameters[0].c_str(), NULL, 10));
else
object["window"] = parameters[0];
}
if (fields.find("windowparameter") != fields.end())
{
if (parameters.size() > 1)
object["windowparameter"] = parameters[1];
else
object["windowparameter"] = "";
}
}
else if (StringUtils::EqualsNoCase(function, "PlayMedia"))
{
object["type"] = "media";
if (fields.find("path") != fields.end())
object["path"] = parameters[0];
}
else if (StringUtils::EqualsNoCase(function, "RunScript"))
{
object["type"] = "script";
if (fields.find("path") != fields.end())
object["path"] = parameters[0];
}
else
object["type"] = "unknown";
if (type.empty() || type.compare(object["type"].asString()) == 0)
result["favourites"].append(object);
}
int start, end;
HandleLimits(parameterObject, result, result["favourites"].size(), start, end);
return OK;
}
示例14: LoadItem
bool CMusicInfoLoader::LoadItem(CFileItem* pItem)
{
if (m_pProgressCallback && !pItem->m_bIsFolder)
m_pProgressCallback->SetProgressAdvance();
if (pItem->m_bIsFolder || pItem->IsPlayList() || pItem->IsNFO() || pItem->IsInternetStream())
return false;
if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded())
return true;
// first check the cached item
CFileItemPtr mapItem = (*m_mapFileItems)[pItem->GetPath()];
if (mapItem && mapItem->m_dateTime==pItem->m_dateTime && mapItem->HasMusicInfoTag() && mapItem->GetMusicInfoTag()->Loaded())
{ // Query map if we previously cached the file on HD
*pItem->GetMusicInfoTag() = *mapItem->GetMusicInfoTag();
pItem->SetArt("thumb", mapItem->GetArt("thumb"));
return true;
}
CStdString strPath;
URIUtils::GetDirectory(pItem->GetPath(), strPath);
URIUtils::AddSlashAtEnd(strPath);
if (strPath!=m_strPrevPath)
{
// The item is from another directory as the last one,
// query the database for the new directory...
m_musicDatabase.GetSongsByPath(strPath, m_songsMap);
m_databaseHits++;
}
CSong *song=NULL;
if ((song=m_songsMap.Find(pItem->GetPath()))!=NULL)
{ // Have we loaded this item from database before
pItem->GetMusicInfoTag()->SetSong(*song);
pItem->SetArt("thumb", song->strThumb);
}
else if (pItem->IsMusicDb())
{ // a music db item that doesn't have tag loaded - grab details from the database
XFILE::MUSICDATABASEDIRECTORY::CQueryParams param;
XFILE::MUSICDATABASEDIRECTORY::CDirectoryNode::GetDatabaseInfo(pItem->GetPath(),param);
CSong song;
if (m_musicDatabase.GetSongById(param.GetSongId(), song))
{
pItem->GetMusicInfoTag()->SetSong(song);
pItem->SetArt("thumb", song.strThumb);
}
}
else if (g_guiSettings.GetBool("musicfiles.usetags") || pItem->IsCDDA())
{ // Nothing found, load tag from file,
// always try to load cddb info
// get correct tag parser
auto_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(pItem->GetPath()));
if (NULL != pLoader.get())
// get tag
pLoader->Load(pItem->GetPath(), *pItem->GetMusicInfoTag());
m_tagReads++;
}
m_strPrevPath = strPath;
return true;
}
示例15: OnMessage
bool CGUIDialogVideoInfo::OnMessage(CGUIMessage& message)
{
switch ( message.GetMessage() )
{
case GUI_MSG_WINDOW_DEINIT:
{
ClearCastList();
}
break;
case GUI_MSG_CLICKED:
{
int iControl = message.GetSenderId();
if (iControl == CONTROL_BTN_REFRESH)
{
if (m_movieItem->GetVideoInfoTag()->m_iSeason < 0 && !m_movieItem->GetVideoInfoTag()->m_strShowTitle.IsEmpty()) // tv show
{
bool bCanceled=false;
if (CGUIDialogYesNo::ShowAndGetInput(20377,20378,-1,-1,bCanceled))
{
m_bRefreshAll = true;
CVideoDatabase db;
if (db.Open())
{
db.SetPathHash(m_movieItem->GetVideoInfoTag()->m_strPath,"");
db.Close();
}
}
else
m_bRefreshAll = false;
if (bCanceled)
return false;
}
m_bRefresh = true;
Close();
return true;
}
else if (iControl == CONTROL_BTN_TRACKS)
{
m_bViewReview = !m_bViewReview;
Update();
}
else if (iControl == CONTROL_BTN_PLAY)
{
Play();
}
else if (iControl == CONTROL_BTN_RESUME)
{
Play(true);
}
else if (iControl == CONTROL_BTN_GET_THUMB)
{
OnGetArt();
}
else if (iControl == CONTROL_BTN_PLAY_TRAILER)
{
PlayTrailer();
}
else if (iControl == CONTROL_BTN_GET_FANART)
{
OnGetFanart();
}
else if (iControl == CONTROL_BTN_DIRECTOR)
{
CStdString strDirector = StringUtils::Join(m_movieItem->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
OnSearch(strDirector);
}
else if (iControl == CONTROL_LIST)
{
int iAction = message.GetParam1();
if (ACTION_SELECT_ITEM == iAction || ACTION_MOUSE_LEFT_CLICK == iAction)
{
CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl);
OnMessage(msg);
int iItem = msg.GetParam1();
if (iItem < 0 || iItem >= m_castList->Size())
break;
CStdString strItem = m_castList->Get(iItem)->GetLabel();
CStdString strFind;
strFind.Format(" %s ",g_localizeStrings.Get(20347));
int iPos = strItem.Find(strFind);
if (iPos == -1)
iPos = strItem.size();
CStdString tmp = strItem.Left(iPos);
OnSearch(tmp);
}
}
}
break;
case GUI_MSG_NOTIFY_ALL:
{
if (IsActive() && message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem())
{
CFileItemPtr item = boost::static_pointer_cast<CFileItem>(message.GetItem());
if (item && m_movieItem->GetPath().Equals(item->GetPath()))
{ // Just copy over the stream details and the thumb if we don't already have one
if (!m_movieItem->HasArt("thumb"))
m_movieItem->SetArt("thumb", item->GetArt("thumb"));
m_movieItem->GetVideoInfoTag()->m_streamDetails = item->GetVideoInfoTag()->m_streamDetails;
//.........这里部分代码省略.........