bool CThumbLoader::CheckAndCacheThumb(CFileItem &item) { if (item.HasThumbnail() && !g_TextureManager.CanLoad(item.GetThumbnailImage())) { CStdString thumb = CTextureCache::Get().CheckAndCacheImage(item.GetThumbnailImage()); item.SetThumbnailImage(thumb); return !thumb.IsEmpty(); } return false; }
void CGUIWindowVisualisation::ShowOSD() { CGUIDialogBoxeeMusicCtx* pDlgInfo = (CGUIDialogBoxeeMusicCtx*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_MUSIC_CTX); CPlayList& pl = g_playlistPlayer.GetPlaylist(g_playlistPlayer.GetCurrentPlaylist()); int nSong = g_playlistPlayer.GetCurrentSong(); CFileItem *pItem = NULL; if ( nSong < pl.size() && nSong >= 0) pItem = pl[nSong].get(); if (pItem == NULL) pItem = &g_application.CurrentFileItem(); if (pDlgInfo && pItem ) { if (pItem->GetThumbnailImage().IsEmpty()) pItem->SetThumbnailImage(g_infoManager.GetImage(MUSICPLAYER_COVER,0)); pDlgInfo->SetItem(*pItem); pDlgInfo->DoModal(); } g_infoManager.SetShowInfo(false); }
bool CProgramThumbLoader::FillThumb(CFileItem &item) { // no need to do anything if we already have a thumb set CStdString thumb = item.GetThumbnailImage(); if (thumb.IsEmpty()) { // see whether we have a cached image for this item thumb = GetCachedImage(item, "thumb"); if (thumb.IsEmpty()) { thumb = GetLocalThumb(item); if (!thumb.IsEmpty()) SetCachedImage(item, "thumb", thumb); } } if (!thumb.IsEmpty()) { CTextureCache::Get().BackgroundCacheImage(thumb); item.SetThumbnailImage(thumb); } return true; }
int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString& strDirectory) { CSongMap songsMap; // get all information for all files in current directory from database, and remove them if (m_musicDatabase.RemoveSongsFromPath(strDirectory, songsMap)) m_needsCleanup = true; VECSONGS songsToAdd; // for every file found, but skip folder for (int i = 0; i < items.Size(); ++i) { CFileItem* pItem = items[i]; CStdString strExtension; CUtil::GetExtension(pItem->m_strPath, strExtension); if (m_bStop) return 0; // dont try reading id3tags for folders, playlists or shoutcast streams if (!pItem->m_bIsFolder && !pItem->IsPlayList() && !pItem->IsShoutCast() && !pItem->IsPicture()) { m_currentItem++; // CLog::Log(LOGDEBUG, "%s - Reading tag for: %s", __FUNCTION__, pItem->m_strPath.c_str()); // grab info from the song CSong *dbSong = songsMap.Find(pItem->m_strPath); CMusicInfoTag& tag = *pItem->GetMusicInfoTag(); if (!tag.Loaded() ) { // read the tag from a file auto_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(pItem->m_strPath)); if (NULL != pLoader.get()) pLoader->Load(pItem->m_strPath, tag); } // if we have the itemcount, notify our // observer with the progress we made if (m_pObserver && m_itemCount>0) m_pObserver->OnSetProgress(m_currentItem, m_itemCount); if (tag.Loaded()) { CSong song(tag); song.iStartOffset = pItem->m_lStartOffset; song.iEndOffset = pItem->m_lEndOffset; if (dbSong) { // keep the db-only fields intact on rescan... song.iTimesPlayed = dbSong->iTimesPlayed; song.lastPlayed = dbSong->lastPlayed; if (song.rating == '0') song.rating = dbSong->rating; } pItem->SetMusicThumb(); song.strThumb = pItem->GetThumbnailImage(); songsToAdd.push_back(song); // CLog::Log(LOGDEBUG, "%s - Tag loaded for: %s", __FUNCTION__, spItem->m_strPath.c_str()); } else CLog::Log(LOGDEBUG, "%s - No tag found for: %s", __FUNCTION__, pItem->m_strPath.c_str()); } } CheckForVariousArtists(songsToAdd); if (!items.HasThumbnail()) UpdateFolderThumb(songsToAdd, items.m_strPath); // finally, add these to the database for (unsigned int i = 0; i < songsToAdd.size(); ++i) { if (m_bStop) return i; CSong &song = songsToAdd[i]; m_musicDatabase.AddSong(song, false); if (!m_bStop && g_guiSettings.GetBool("musiclibrary.autoartistinfo")) { long iArtist = m_musicDatabase.GetArtistByName(song.strArtist); CStdString strPath; strPath.Format("musicdb://2/%u/",iArtist); if (find(m_artistsScanned.begin(),m_artistsScanned.end(),iArtist) == m_artistsScanned.end()) if (DownloadArtistInfo(strPath,song.strArtist)) m_artistsScanned.push_back(iArtist); if (m_pObserver) m_pObserver->OnStateChanged(READING_MUSIC_INFO); } if (!m_bStop && g_guiSettings.GetBool("musiclibrary.autoalbuminfo")) { long iAlbum = m_musicDatabase.GetAlbumByName(song.strAlbum,song.strArtist); CStdString strPath; strPath.Format("musicdb://3/%u/",iAlbum); CMusicAlbumInfo albumInfo; bool bCanceled; if (find(m_albumsScanned.begin(),m_albumsScanned.end(),iAlbum) == m_albumsScanned.end()) if (DownloadAlbumInfo(strPath,song.strArtist,song.strAlbum,bCanceled,albumInfo)) m_albumsScanned.push_back(iAlbum); if (m_pObserver) m_pObserver->OnStateChanged(READING_MUSIC_INFO); } } return songsToAdd.size(); }
bool CGUIWindowVideoNav::GetDirectory(const CStdString &strDirectory, CFileItemList &items) { if (m_bDisplayEmptyDatabaseMessage) return true; CFileItem directory(strDirectory, true); if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); m_rootDir.SetCacheDirectory(DIR_CACHE_NEVER); items.ClearProperties(); bool bResult = CGUIWindowVideoBase::GetDirectory(strDirectory, items); if (bResult) { if (items.IsVideoDb()) { XFILE::CVideoDatabaseDirectory dir; CQueryParams params; dir.GetQueryParams(items.m_strPath,params); VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(items.m_strPath); items.SetThumbnailImage(""); if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_EPISODES || node == NODE_TYPE_SEASONS || node == NODE_TYPE_RECENTLY_ADDED_EPISODES) { CLog::Log(LOGDEBUG, "WindowVideoNav::GetDirectory"); // grab the show thumb CFileItem showItem; m_database.GetFilePathById(params.GetTvShowId(),showItem.m_strPath,VIDEODB_CONTENT_TVSHOWS); showItem.SetVideoThumb(); items.SetProperty("tvshowthumb", showItem.GetThumbnailImage()); // Grab fanart data CVideoInfoTag details; m_database.GetTvShowInfo(showItem.m_strPath, details, params.GetTvShowId()); items.SetProperty("fanart_color1", details.m_fanart.GetColor(0)); items.SetProperty("fanart_color2", details.m_fanart.GetColor(1)); items.SetProperty("fanart_color3", details.m_fanart.GetColor(2)); if (showItem.CacheLocalFanart()) items.SetProperty("fanart_image", showItem.GetCachedFanart()); // save the show description (showplot) items.SetProperty("showplot", details.m_strPlot); // set the season thumb CStdString strLabel; if (params.GetSeason() == 0) strLabel = g_localizeStrings.Get(20381); else strLabel.Format(g_localizeStrings.Get(20358), params.GetSeason()); CFileItem item(strLabel); CUtil::GetParentPath(items.m_strPath,item.m_strPath); item.m_bIsFolder = true; item.SetCachedSeasonThumb(); if (item.HasThumbnail()) items.SetProperty("seasonthumb",item.GetThumbnailImage()); // the container folder thumb is the parent (i.e. season or show) if (node == NODE_TYPE_EPISODES || node == NODE_TYPE_RECENTLY_ADDED_EPISODES) { items.SetContent("episodes"); // grab the season thumb as the folder thumb CStdString strLabel; CStdString strPath; if (params.GetSeason() == -1 && items.Size() > 0) { CQueryParams params2; dir.GetQueryParams(items[0]->m_strPath,params2); strLabel.Format(g_localizeStrings.Get(20358), params2.GetSeason()); CUtil::GetParentPath(items.m_strPath,strPath); } else { if (params.GetSeason() == 0) strLabel = g_localizeStrings.Get(20381); else strLabel.Format(g_localizeStrings.Get(20358), params.GetSeason()); strPath = items.m_strPath; } CFileItem item(strLabel); item.m_strPath = strPath; item.m_bIsFolder = true; item.GetVideoInfoTag()->m_strPath = showItem.m_strPath; item.SetCachedSeasonThumb(); items.SetThumbnailImage(item.GetThumbnailImage()); items.SetProperty("seasonthumb",item.GetThumbnailImage()); } else { items.SetContent("seasons"); items.SetThumbnailImage(showItem.GetThumbnailImage()); } } else if (node == NODE_TYPE_TITLE_MOVIES || node == NODE_TYPE_RECENTLY_ADDED_MOVIES) items.SetContent("movies"); else if (node == NODE_TYPE_TITLE_TVSHOWS) items.SetContent("tvshows"); else if (node == NODE_TYPE_TITLE_MUSICVIDEOS || node == NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS) items.SetContent("musicvideos"); else if (node == NODE_TYPE_GENRE) items.SetContent("genres"); else if (node == NODE_TYPE_COUNTRY) items.SetContent("countries"); else if (node == NODE_TYPE_ACTOR) { if (params.GetContentType() == VIDEODB_CONTENT_MUSICVIDEOS) items.SetContent("artists"); else items.SetContent("actors"); } else if (node == NODE_TYPE_DIRECTOR) items.SetContent("directors"); else if (node == NODE_TYPE_STUDIO) items.SetContent("studios"); else if (node == NODE_TYPE_YEAR) items.SetContent("years"); else if (node == NODE_TYPE_MUSICVIDEOS_ALBUM) items.SetContent("albums"); else items.SetContent(""); } } return bResult; }