void CMusicInfoTag::SetAlbum(const CAlbum& album) { Clear(); //Set all artist infomation from album artist credits and artist description SetArtistDesc(album.GetAlbumArtistString()); SetArtist(album.GetAlbumArtist()); SetMusicBrainzArtistID(album.GetMusicBrainzAlbumArtistID()); SetAlbumArtistDesc(album.GetAlbumArtistString()); SetAlbumArtist(album.GetAlbumArtist()); SetMusicBrainzAlbumArtistID(album.GetMusicBrainzAlbumArtistID()); SetAlbumId(album.idAlbum); SetAlbum(album.strAlbum); SetTitle(album.strAlbum); SetMusicBrainzAlbumID(album.strMusicBrainzAlbumID); SetMusicBrainzReleaseType(album.strType); SetGenre(album.genre); SetMood(StringUtils::Join(album.moods, g_advancedSettings.m_musicItemSeparator)); SetRecordLabel(album.strLabel); SetRating(album.fRating); SetUserrating(album.iUserrating); SetVotes(album.iVotes); SetCompilation(album.bCompilation); SYSTEMTIME stTime; stTime.wYear = album.iYear; SetReleaseDate(stTime); SetAlbumReleaseType(album.releaseType); SetDateAdded(album.dateAdded); SetPlayCount(album.iTimesPlayed); SetDatabaseId(album.idAlbum, MediaTypeAlbum); SetLastPlayed(album.lastPlayed); SetLoaded(); }
void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const std::string &path) { // check user permissions bool saveDb = album.idAlbum != -1; bool saveDirThumb = true; if (!CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser) { saveDb = false; saveDirThumb = false; } std::string albumThumb = m_musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb"); // Update the thumb in the music database (songs + albums) std::string 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.GetAlbumArtist() == tag->GetAlbumArtist() || album.GetAlbumArtist() == 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 thumbnails 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(); }