本文整理汇总了C++中CMusicThumbLoader类的典型用法代码示例。如果您正苦于以下问题:C++ CMusicThumbLoader类的具体用法?C++ CMusicThumbLoader怎么用?C++ CMusicThumbLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMusicThumbLoader类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: albumPath
void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &path)
{
// check user permissions
bool saveDb = album.idAlbum != -1;
bool saveDirThumb = true;
if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
{
saveDb = false;
saveDirThumb = false;
}
CStdString albumThumb = m_musicdatabase.GetArtForItem(album.idAlbum, "album", "thumb");
// Update the thumb in the music database (songs + albums)
CStdString albumPath(path);
if (saveDb && CFile::Exists(albumThumb))
m_musicdatabase.SaveAlbumThumb(album.idAlbum, albumThumb);
// Update currently playing song if it's from the same album. This is necessary as when the album
// first gets it's cover, the info manager's item doesn't have the updated information (so will be
// sending a blank thumb to the skin.)
if (g_application.m_pPlayer->IsPlayingAudio())
{
const CMusicInfoTag* tag=g_infoManager.GetCurrentSongTag();
if (tag)
{
// really, this may not be enough as it is to reliably update this item. eg think of various artists albums
// that aren't tagged as such (and aren't yet scanned). But we probably can't do anything better than this
// in that case
if (album.strAlbum == tag->GetAlbum() && (album.artist == tag->GetAlbumArtist() ||
album.artist == tag->GetArtist()))
{
g_infoManager.SetCurrentAlbumThumb(albumThumb);
}
}
}
// Save this thumb as the directory thumb if it's the only album in the folder (files view nicety)
// We do this by grabbing all the songs in the folder, and checking to see whether they come
// from the same album.
if (saveDirThumb && CFile::Exists(albumThumb) && !albumPath.empty() && !URIUtils::IsCDDA(albumPath))
{
CFileItemList items;
GetDirectory(albumPath, items);
OnRetrieveMusicInfo(items);
VECALBUMS albums;
CMusicInfoScanner::FileItemsToAlbums(items, albums);
if (albums.size() == 1)
{ // set as folder thumb as well
CMusicThumbLoader loader;
loader.SetCachedImage(items, "thumb", albumPath);
}
}
// update the file listing - we have to update the whole lot, as it's likely that
// more than just our thumbnaias changed
// TODO: Ideally this would only be done when needed - at the moment we appear to be
// doing this for every lookup, possibly twice (see ShowAlbumInfo)
Refresh(true);
// Do we have to autoswitch to the thumb control?
m_guiState.reset(CGUIViewState::GetViewState(GetID(), *m_vecItems));
UpdateButtons();
}
示例2: album
void CMusicInfoScanner::FindArtForAlbums(VECALBUMS &albums, const std::string &path)
{
/*
If there's a single album in the folder, then art can be taken from
the folder art.
*/
std::string albumArt;
if (albums.size() == 1)
{
CFileItem album(path, true);
albumArt = album.GetUserMusicThumb(true);
if (!albumArt.empty())
albums[0].art["thumb"] = albumArt;
}
for (VECALBUMS::iterator i = albums.begin(); i != albums.end(); ++i)
{
CAlbum &album = *i;
if (albums.size() != 1)
albumArt = "";
/*
Find art that is common across these items
If we find a single art image we treat it as the album art
and discard song art else we use first as album art and
keep everything as song art.
*/
bool singleArt = true;
CSong *art = NULL;
for (VECSONGS::iterator k = album.songs.begin(); k != album.songs.end(); ++k)
{
CSong &song = *k;
if (song.HasArt())
{
if (art && !art->ArtMatches(song))
{
singleArt = false;
break;
}
if (!art)
art = &song;
}
}
/*
assign the first art found to the album - better than no art at all
*/
if (art && albumArt.empty())
{
if (!art->strThumb.empty())
albumArt = art->strThumb;
else
albumArt = CTextureUtils::GetWrappedImageURL(art->strFileName, "music");
}
if (!albumArt.empty())
album.art["thumb"] = albumArt;
if (singleArt)
{ //if singleArt then we can clear the artwork for all songs
for (VECSONGS::iterator k = album.songs.begin(); k != album.songs.end(); ++k)
k->strThumb.clear();
}
else
{ // more than one piece of art was found for these songs, so cache per song
for (VECSONGS::iterator k = album.songs.begin(); k != album.songs.end(); ++k)
{
if (k->strThumb.empty() && !k->embeddedArt.empty())
k->strThumb = CTextureUtils::GetWrappedImageURL(k->strFileName, "music");
}
}
}
if (albums.size() == 1 && !albumArt.empty())
{
// assign to folder thumb as well
CFileItem albumItem(path, true);
CMusicThumbLoader loader;
loader.SetCachedImage(albumItem, "thumb", albumArt);
}
}
示例3: 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.OnLoaderStart();
musicdatabase.Open();
if (musicdatabase.GetRecentlyAddedAlbumSongs("musicdb://songs/", musicItems, NUM_ITEMS))
{
long idAlbum = -1;
std::string strAlbumThumb;
std::string strAlbumFanart;
for (; i < musicItems.Size(); ++i)
{
CFileItemPtr item = musicItems.Get(i);
std::string value = StringUtils::Format("%i", i + 1);
std::string strRating;
std::string strAlbum = item->GetMusicInfoTag()->GetAlbum();
std::string strArtist = item->GetMusicInfoTag()->GetArtistString();
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 = StringUtils::Format("%c", item->GetMusicInfoTag()->GetUserrating());
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)
{
std::string value = StringUtils::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)
{
CAlbum& album=albums[i];
std::string value = StringUtils::Format("%i", i + 1);
std::string strThumb = musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb");
std::string strFanart = musicdatabase.GetArtistArtForItem(album.idAlbum, MediaTypeAlbum, "fanart");
std::string strDBpath = StringUtils::Format("musicdb://albums/%li/", album.idAlbum);
home->SetProperty("LatestAlbum." + value + ".Title" , album.strAlbum);
home->SetProperty("LatestAlbum." + value + ".Year" , album.iYear);
home->SetProperty("LatestAlbum." + value + ".Artist" , album.GetAlbumArtistString());
home->SetProperty("LatestAlbum." + value + ".Rating" , album.iRating);
home->SetProperty("LatestAlbum." + value + ".Path" , strDBpath);
home->SetProperty("LatestAlbum." + value + ".Thumb" , strThumb);
home->SetProperty("LatestAlbum." + value + ".Fanart" , strFanart);
}
}
for (; i < NUM_ITEMS; ++i)
{
std::string value = StringUtils::Format("%i", i + 1);
home->SetProperty("LatestAlbum." + value + ".Title" , "");
home->SetProperty("LatestAlbum." + value + ".Year" , "");
home->SetProperty("LatestAlbum." + value + ".Artist" , "");
home->SetProperty("LatestAlbum." + value + ".Rating" , "");
home->SetProperty("LatestAlbum." + value + ".Path" , "");
home->SetProperty("LatestAlbum." + value + ".Thumb" , "");
//.........这里部分代码省略.........
示例4: GetDirectory
bool CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileItemList &items)
{
items.ClearArt();
bool bResult = CGUIMediaWindow::GetDirectory(strDirectory, items);
if (bResult)
{
CMusicThumbLoader loader;
loader.FillThumb(items);
CQueryParams params;
CDirectoryNode::GetDatabaseInfo(items.GetPath(), params);
if (params.GetAlbumId() > 0)
{
std::map<std::string, std::string> artistArt;
if (m_musicdatabase.GetArtistArtForItem(params.GetAlbumId(), MediaTypeAlbum, artistArt))
items.AppendArt(artistArt, MediaTypeArtist);
std::map<std::string, std::string> albumArt;
if (m_musicdatabase.GetArtForItem(params.GetAlbumId(), MediaTypeAlbum, albumArt))
items.AppendArt(albumArt, MediaTypeAlbum);
}
if (params.GetArtistId() > 0)
{
std::map<std::string, std::string> artistArt;
if (m_musicdatabase.GetArtForItem(params.GetArtistId(), "artist", artistArt))
items.AppendArt(artistArt, MediaTypeArtist);
}
// add in the "New Playlist" item if we're in the playlists folder
if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://"))
{
CFileItemPtr newPlaylist(new CFileItem(CProfilesManager::GetInstance().GetUserDataItem("PartyMode.xsp"),false));
newPlaylist->SetLabel(g_localizeStrings.Get(16035));
newPlaylist->SetLabelPreformated(true);
newPlaylist->m_bIsFolder = true;
items.Add(newPlaylist);
newPlaylist.reset(new CFileItem("newplaylist://", false));
newPlaylist->SetLabel(g_localizeStrings.Get(525));
newPlaylist->SetLabelPreformated(true);
newPlaylist->SetSpecialSort(SortSpecialOnBottom);
newPlaylist->SetCanQueue(false);
items.Add(newPlaylist);
newPlaylist.reset(new CFileItem("newsmartplaylist://music", false));
newPlaylist->SetLabel(g_localizeStrings.Get(21437));
newPlaylist->SetLabelPreformated(true);
newPlaylist->SetSpecialSort(SortSpecialOnBottom);
newPlaylist->SetCanQueue(false);
items.Add(newPlaylist);
}
// check for .CUE files here.
items.FilterCueItems();
std::string label;
if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::GetInstance().GetSources("music"), &label))
items.SetLabel(label);
}
return bResult;
}
示例5: 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;
musicdatabase.Open();
if (musicdatabase.GetRecentlyAddedAlbumSongs("musicdb://", 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->GetThumbnailImage();
strAlbumFanart = item->GetProperty("fanart_image").asString();
}
}
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);
home->SetProperty("LatestAlbum." + value + ".Fanart" , strFanart);
//.........这里部分代码省略.........
示例6: if
void CFileItemHandler::FillDetails(ISerializable* info, CFileItemPtr item, const CVariant& fields, CVariant &result)
{
if (info == NULL || fields.size() == 0)
return;
CVariant serialization;
info->Serialize(serialization);
bool fetchedArt = false;
for (unsigned int i = 0; i < fields.size(); i++)
{
CStdString field = fields[i].asString();
if (item)
{
if (item->IsAlbum() && field.Equals("albumlabel"))
field = "label";
if (item->IsAlbum())
{
if (field == "label")
{
result["albumlabel"] = item->GetProperty("album_label");
continue;
}
if (item->HasProperty("album_" + field + "_array"))
{
result[field] = item->GetProperty("album_" + field + "_array");
continue;
}
if (item->HasProperty("album_" + field))
{
result[field] = item->GetProperty("album_" + field);
continue;
}
}
if (item->HasProperty("artist_" + field + "_array"))
{
result[field] = item->GetProperty("artist_" + field + "_array");
continue;
}
if (item->HasProperty("artist_" + field))
{
result[field] = item->GetProperty("artist_" + field);
continue;
}
if (field == "thumbnail")
{
if (item->HasVideoInfoTag())
{
if (!item->HasThumbnail() && !fetchedArt && item->GetVideoInfoTag()->m_iDbId > -1)
{
CVideoThumbLoader loader;
loader.FillLibraryArt(item.get());
fetchedArt = true;
}
}
else if (item->HasPictureInfoTag())
{
if (!item->HasThumbnail())
item->SetThumbnailImage(CTextureCache::GetWrappedThumbURL(item->GetPath()));
}
else if (item->HasMusicInfoTag())
{
if (!item->HasThumbnail() && !fetchedArt && item->GetMusicInfoTag()->GetDatabaseId() > -1)
{
CMusicThumbLoader loader;
loader.FillLibraryArt(*item);
fetchedArt = true;
}
}
if (item->HasThumbnail())
result["thumbnail"] = CTextureCache::GetWrappedImageURL(item->GetThumbnailImage());
if (!result.isMember("thumbnail"))
result["thumbnail"] = "";
continue;
}
if (field == "fanart")
{
if (item->HasVideoInfoTag())
{
if (!item->HasProperty("fanart_image") && !fetchedArt && item->GetVideoInfoTag()->m_iDbId > -1)
{
CVideoThumbLoader loader;
loader.FillLibraryArt(item.get());
fetchedArt = true;
}
if (item->HasProperty("fanart_image"))
result["fanart"] = CTextureCache::GetWrappedImageURL(item->GetProperty("fanart_image").asString());
}
else if (item->HasMusicInfoTag())
{
if (!item->HasProperty("fanart_image") && !fetchedArt && item->GetMusicInfoTag()->GetDatabaseId() > -1)
{
CMusicThumbLoader loader;
loader.FillLibraryArt(*item);
fetchedArt = true;
//.........这里部分代码省略.........
示例7: DoWork
// Fetch full album/artist information including art types list
bool DoWork() override
{
CGUIDialogMusicInfo *dialog = CServiceBroker::GetGUI()->GetWindowManager().
GetWindow<CGUIDialogMusicInfo>(WINDOW_DIALOG_MUSIC_INFO);
if (!dialog)
return false;
if (dialog->IsCancelled())
return false;
CFileItemPtr m_item = dialog->GetCurrentListItem();
CMusicInfoTag& tag = *m_item->GetMusicInfoTag();
CMusicDatabase database;
database.Open();
// May only have partially populated item, so fetch all artist or album data from db
if (tag.GetType() == MediaTypeArtist)
{
int artistId = tag.GetDatabaseId();
CArtist artist;
if (!database.GetArtist(artistId, artist))
return false;
tag.SetArtist(artist);
CMusicDatabase::SetPropertiesFromArtist(*m_item, artist);
m_item->SetLabel(artist.strArtist);
// Get artist folder where local art could be found
// Get the *name* of the folder for this artist within the Artist Info folder (may not exist).
// If there is no Artist Info folder specified in settings this will be blank
database.GetArtistPath(artist, artist.strPath);
// Get the old location for those album artists with a unique folder (local to music files)
// If there is no folder for the artist and *only* the artist this will be blank
std::string oldartistpath;
bool oldpathfound = database.GetOldArtistPath(artist.idArtist, oldartistpath);
// Set up path for *item folder when browsing for art, by default this is
// in the Artist Info Folder (when it exists), but could end up blank
std::string artistItemPath = artist.strPath;
if (!CDirectory::Exists(artistItemPath))
{
// Fall back local to music files (historic location for those album artists with a unique folder)
// although there may not be such a unique folder for the arist
if (oldpathfound)
artistItemPath = oldartistpath;
else
// Fall back further to browse the Artist Info Folder itself
artistItemPath = CServiceBroker::GetSettings().GetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSFOLDER);
}
m_item->SetPath(artistItemPath);
// Store info as CArtist as well as item properties
dialog->SetArtist(artist, oldartistpath);
// Fetch artist discography as scraped from online sources, but always
// include all the albums in the music library
dialog->SetDiscography(database);
}
else
{
// tag.GetType == MediaTypeAlbum
int albumId = tag.GetDatabaseId();
CAlbum album;
if (!database.GetAlbum(albumId, album))
return false;
tag.SetAlbum(album);
CMusicDatabase::SetPropertiesFromAlbum(*m_item, album);
// Get album folder where local art could be found
database.GetAlbumPath(albumId, album.strPath);
// Set up path for *item folder when browsing for art
m_item->SetPath(album.strPath);
// Store info as CAlbum as well as item properties
dialog->SetAlbum(album, album.strPath);
// Set the list of songs and related art
dialog->SetSongs(album.songs);
}
database.Close();
/*
Load current art (to CGUIListItem.m_art)
For albums this includes related artist(s) art and artist fanart set as
fallback album fanart.
Clear item art first to ensure fresh not cached/partial art
*/
m_item->ClearArt();
CMusicThumbLoader loader;
loader.LoadItem(m_item.get());
// Fill vector of possible art types with current art, when it exists,
// for display on the art type selection dialog
CFileItemList artlist;
MUSIC_UTILS::FillArtTypesList(*m_item, artlist);
dialog->SetArtTypeList(artlist);
if (dialog->IsCancelled())
return false;
// Tell waiting MusicDialog that job is complete
dialog->FetchComplete();
return true;
//.........这里部分代码省略.........