本文整理汇总了C++中CFileItemPtr::GetMusicInfoTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemPtr::GetMusicInfoTag方法的具体用法?C++ CFileItemPtr::GetMusicInfoTag怎么用?C++ CFileItemPtr::GetMusicInfoTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemPtr
的用法示例。
在下文中一共展示了CFileItemPtr::GetMusicInfoTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CacheTrackThumb
void CLastFmManager::CacheTrackThumb(const int nrInitialTracksToAdd)
{
unsigned int start = XbmcThreads::SystemClockMillis();
CSingleLock lock(m_lockCache);
int iNrCachedTracks = m_RadioTrackQueue->size();
CCurlFile http;
for (int i = 0; i < nrInitialTracksToAdd && i < iNrCachedTracks; i++)
{
CFileItemPtr item = (*m_RadioTrackQueue)[i];
if (!item->GetMusicInfoTag()->Loaded())
{
if (!item->HasThumbnail())
{
item->SetThumbnailImage("DefaultAlbumCover.png");
}
item->GetMusicInfoTag()->SetLoaded();
}
}
CLog::Log(LOGDEBUG, "%s: Done (time: %i ms)", __FUNCTION__, (int)(XbmcThreads::SystemClockMillis() - start));
}
示例2: ByLastPlayed
void SSortFileItem::ByLastPlayed(CFileItemPtr &item)
{
if (!item) return;
if (item->HasVideoInfoTag())
item->SetSortLabel(item->GetVideoInfoTag()->m_lastPlayed.GetAsDBDateTime());
else if (item->HasMusicInfoTag()) // TODO: No last played info in the fileitem for music
item->SetSortLabel(item->GetMusicInfoTag()->GetTitle());
else
item->SetSortLabel(item->GetLabel());
}
示例3: ByYear
void SSortFileItem::ByYear(CFileItemPtr &item)
{
if (!item) return;
CStdString label;
if (item->HasMusicInfoTag())
label.Format("%i %s", item->GetMusicInfoTag()->GetYear(), item->GetLabel().c_str());
else
label.Format("%s %s %i %s", item->GetVideoInfoTag()->m_premiered.GetAsDBDate().c_str(), item->GetVideoInfoTag()->m_firstAired.GetAsDBDate(), item->GetVideoInfoTag()->m_iYear, item->GetLabel().c_str());
item->SetSortLabel(label);
}
示例4: ByPlayCount
void SSortFileItem::ByPlayCount(CFileItemPtr &item)
{
if (!item) return;
CStdString label;
if (item->HasVideoInfoTag())
label.Format("%i %s", item->GetVideoInfoTag()->m_playCount, item->GetLabel().c_str());
if (item->HasMusicInfoTag())
label.Format("%i %s", item->GetMusicInfoTag()->GetPlayCount(), item->GetLabel().c_str());
item->SetSortLabel(label);
}
示例5: BySongAlbumNoThe
void SSortFileItem::BySongAlbumNoThe(CFileItemPtr &item)
{
if (!item) return;
CStdString label;
if (item->HasMusicInfoTag())
label = item->GetMusicInfoTag()->GetAlbum();
else if (item->HasVideoInfoTag())
label = item->GetVideoInfoTag()->m_strAlbum;
label = RemoveArticles(label);
CStdString artist;
if (item->HasMusicInfoTag())
artist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
else if (item->HasVideoInfoTag())
artist = item->GetVideoInfoTag()->m_strArtist;
label += " " + RemoveArticles(artist);
if (item->HasMusicInfoTag())
label.AppendFormat(" %i", item->GetMusicInfoTag()->GetTrackAndDiskNumber());
item->SetSortLabel(label);
}
示例6: BySongAlbum
void SSortFileItem::BySongAlbum(CFileItemPtr &item)
{
if (!item) return;
CStdString label;
if (item->HasMusicInfoTag())
label = item->GetMusicInfoTag()->GetAlbum();
else if (item->HasVideoInfoTag())
label = item->GetVideoInfoTag()->m_strAlbum;
CStdString artist;
if (item->HasMusicInfoTag())
artist = item->GetMusicInfoTag()->GetArtist();
else if (item->HasVideoInfoTag())
artist = item->GetVideoInfoTag()->m_strArtist;
label += " " + artist;
if (item->HasMusicInfoTag())
label.AppendFormat(" %i", item->GetMusicInfoTag()->GetTrackAndDiskNumber());
item->SetSortLabel(label);
}
示例7: OnPrepareFileItems
void CGUIWindowMusicNav::OnPrepareFileItems(CFileItemList &items)
{
CGUIWindowMusicBase::OnPrepareFileItems(items);
// set fanart
map<CStdString, CStdString> artists;
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
if (!item->HasMusicInfoTag() || item->HasProperty("fanart_image"))
continue;
map<CStdString, CStdString>::iterator artist = artists.find(item->GetMusicInfoTag()->GetArtist());
if (artist == artists.end())
{
CStdString strFanart = item->GetCachedFanart();
if (XFILE::CFile::Exists(strFanart))
item->SetProperty("fanart_image",strFanart);
else
strFanart = "";
artists.insert(make_pair(item->GetMusicInfoTag()->GetArtist(), strFanart));
}
else
item->SetProperty("fanart_image",artist->second);
}
}
示例8: SavePlayList
void CGUIWindowMusicPlayList::SavePlayList()
{
CStdString strNewFileName;
if (CGUIKeyboardFactory::ShowAndGetInput(strNewFileName, g_localizeStrings.Get(16012), false))
{
// need 2 rename it
CStdString strFolder, strPath;
URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music", strFolder);
strNewFileName= CUtil::MakeLegalFileName( strNewFileName );
strNewFileName += ".m3u";
URIUtils::AddFileToFolder(strFolder, strNewFileName, strPath);
// get selected item
int iItem = m_viewControl.GetSelectedItem();
CStdString strSelectedItem = "";
if (iItem >= 0 && iItem < m_vecItems->Size())
{
CFileItemPtr pItem = m_vecItems->Get(iItem);
if (!pItem->IsParentFolder())
{
GetDirectoryHistoryString(pItem.get(), strSelectedItem);
}
}
CStdString strOldDirectory = m_vecItems->GetPath();
m_history.SetSelectedItem(strSelectedItem, strOldDirectory);
CPlayListM3U playlist;
for (int i = 0; i < (int)m_vecItems->Size(); ++i)
{
CFileItemPtr pItem = m_vecItems->Get(i);
// Musicdatabase items should contain the real path instead of a musicdb url
// otherwise the user can't save and reuse the playlist when the musicdb gets deleted
if (pItem->IsMusicDb())
pItem->SetPath(pItem->GetMusicInfoTag()->GetURL());
playlist.Add(pItem);
}
CLog::Log(LOGDEBUG, "Saving music playlist: [%s]", strPath.c_str());
playlist.Save(strPath);
Refresh(); // need to update
}
}
示例9: RetrieveMusicInfo
/// \brief Retrieve tag information for \e m_vecItems
void CGUIWindowMusicBase::RetrieveMusicInfo()
{
unsigned int startTick = XbmcThreads::SystemClockMillis();
OnRetrieveMusicInfo(*m_vecItems);
// \todo Scan for multitrack items here...
vector<string> itemsForRemove;
CFileItemList itemsForAdd;
for (int i = 0; i < m_vecItems->Size(); ++i)
{
CFileItemPtr pItem = (*m_vecItems)[i];
if (pItem->m_bIsFolder || pItem->IsPlayList() || pItem->IsPicture() || pItem->IsLyrics())
continue;
CMusicInfoTag& tag = *pItem->GetMusicInfoTag();
if (tag.Loaded() && !tag.GetCueSheet().empty())
pItem->LoadEmbeddedCue();
if (pItem->HasCueDocument()
&& pItem->LoadTracksFromCueDocument(itemsForAdd))
{
itemsForRemove.push_back(pItem->GetPath());
}
}
for (size_t i = 0; i < itemsForRemove.size(); ++i)
{
for (int j = 0; j < m_vecItems->Size(); ++j)
{
if ((*m_vecItems)[j]->GetPath() == itemsForRemove[i])
{
m_vecItems->Remove(j);
break;
}
}
}
m_vecItems->Append(itemsForAdd);
CLog::Log(LOGDEBUG, "RetrieveMusicInfo() took %u msec",
XbmcThreads::SystemClockMillis() - startTick);
}
示例10: AddToPlaylist
void CLastFmManager::AddToPlaylist(const int nrTracks)
{
CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
for (int i = 0; i < nrTracks; i++)
{
int iNrCachedTracks = m_RadioTrackQueue->size();
if (iNrCachedTracks > 0)
{
CFileItemPtr item = (*m_RadioTrackQueue)[0];
if (item->GetMusicInfoTag()->Loaded())
{
CSingleLock lock(m_lockCache);
m_RadioTrackQueue->Remove(0);
CSingleLock lock2(m_lockPlaylist);
playlist.Add(item);
}
else
{
break;
}
}
}
}
示例11: ResolveURL
void CPlayListM3U::Save(const std::string& strFileName) const
{
if (!m_vecItems.size())
return;
std::string strPlaylist = CUtil::MakeLegalPath(strFileName);
CFile file;
if (!file.OpenForWrite(strPlaylist,true))
{
CLog::Log(LOGERROR, "Could not save M3U playlist: [%s]", strPlaylist.c_str());
return;
}
std::string strLine = StringUtils::Format("%s\n",M3U_START_MARKER);
if (file.Write(strLine.c_str(), strLine.size()) != strLine.size())
return; // error
for (int i = 0; i < (int)m_vecItems.size(); ++i)
{
CFileItemPtr item = m_vecItems[i];
std::string strDescription=item->GetLabel();
g_charsetConverter.utf8ToStringCharset(strDescription);
strLine = StringUtils::Format( "%s:%i,%s\n", M3U_INFO_MARKER, item->GetMusicInfoTag()->GetDuration() / 1000, strDescription.c_str() );
if (file.Write(strLine.c_str(), strLine.size()) != strLine.size())
return; // error
if (item->m_lStartOffset != 0 || item->m_lEndOffset != 0)
{
strLine = StringUtils::Format("%s:%i,%i\n", M3U_OFFSET_MARKER, item->m_lStartOffset, item->m_lEndOffset);
file.Write(strLine.c_str(),strLine.size());
}
std::string strFileName = ResolveURL(item);
g_charsetConverter.utf8ToStringCharset(strFileName);
strLine = StringUtils::Format("%s\n",strFileName.c_str());
if (file.Write(strLine.c_str(), strLine.size()) != strLine.size())
return; // error
}
file.Close();
}
示例12: 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;
}
示例13: RetrieveMusicInfo
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;
CStdStringArray regexps = g_advancedSettings.m_audioExcludeFromScanRegExps;
// for every file found, but skip folder
for (int i = 0; i < items.Size(); ++i)
{
CFileItemPtr pItem = items[i];
CStdString strExtension;
URIUtils::GetExtension(pItem->GetPath(), strExtension);
if (m_bStop)
return 0;
// Discard all excluded files defined by m_musicExcludeRegExps
if (CUtil::ExcludeFileOrFolder(pItem->GetPath(), regexps))
continue;
// dont try reading id3tags for folders, playlists or shoutcast streams
if (!pItem->m_bIsFolder && !pItem->IsPlayList() && !pItem->IsPicture() && !pItem->IsLyrics() )
{
m_currentItem++;
// CLog::Log(LOGDEBUG, "%s - Reading tag for: %s", __FUNCTION__, pItem->GetPath().c_str());
// grab info from the song
CSong *dbSong = songsMap.Find(pItem->GetPath());
CMusicInfoTag& tag = *pItem->GetMusicInfoTag();
if (!tag.Loaded() )
{ // read the tag from a file
auto_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(pItem->GetPath()));
if (NULL != pLoader.get())
pLoader->Load(pItem->GetPath(), tag);
}
// if we have the itemcount, update our
// dialog with the progress we made
if (m_handle && m_itemCount>0)
m_handle->SetPercentage(m_currentItem/(float)m_itemCount*100);
if (tag.Loaded())
{
CSong song(tag);
// ensure our song has a valid filename or else it will assert in AddSong()
if (song.strFileName.IsEmpty())
{
// copy filename from path in case UPnP or other tag loaders didn't specify one (FIXME?)
song.strFileName = pItem->GetPath();
// if we still don't have a valid filename, skip the song
if (song.strFileName.IsEmpty())
{
// this shouldn't ideally happen!
CLog::Log(LOGERROR, "Skipping song since it doesn't seem to have a filename");
continue;
}
}
song.iStartOffset = pItem->m_lStartOffset;
song.iEndOffset = pItem->m_lEndOffset;
song.strThumb = pItem->GetUserMusicThumb(true);
if (dbSong)
{ // keep the db-only fields intact on rescan...
song.iTimesPlayed = dbSong->iTimesPlayed;
song.lastPlayed = dbSong->lastPlayed;
song.iKaraokeNumber = dbSong->iKaraokeNumber;
if (song.rating == '0') song.rating = dbSong->rating;
if (song.strThumb.empty())
song.strThumb = dbSong->strThumb;
}
songsToAdd.push_back(song);
// CLog::Log(LOGDEBUG, "%s - Tag loaded for: %s", __FUNCTION__, pItem->GetPath().c_str());
}
else
CLog::Log(LOGDEBUG, "%s - No tag found for: %s", __FUNCTION__, pItem->GetPath().c_str());
}
}
VECALBUMS albums;
CategoriseAlbums(songsToAdd, albums);
FindArtForAlbums(albums, items.GetPath());
// finally, add these to the database
m_musicDatabase.BeginTransaction();
int numAdded = 0;
set<int> albumsToScan;
set<int> artistsToScan;
for (VECALBUMS::iterator i = albums.begin(); i != albums.end(); ++i)
{
vector<int> songIDs;
//.........这里部分代码省略.........
示例14: 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);
//.........这里部分代码省略.........
示例15: BySongTitle
void SSortFileItem::BySongTitle(CFileItemPtr &item)
{
if (!item) return;
item->SetSortLabel(item->GetMusicInfoTag()->GetTitle());
}