Ejemplo n.º 1
0
BOOL CWmp_scrobbler::GetCurrentSong(SONG_INFO* pSong)
{
	USES_CONVERSION;
	IWMPMedia* pMedia = NULL;
	BSTR bstrValue;
	//BSTR bstrName;
	BOOL bRet = FALSE;
	long lCount = 0;
	
	if(	(m_spCore) &&
		(pSong != NULL))
	{
		m_spCore->get_currentMedia(&pMedia);
		
		if(pMedia != NULL)
		{
			pMedia->get_attributeCount(&lCount);

/*
			for(long i = 0; i <= lCount; i++)
			{
				pMedia->getAttributeName(i, &bstrName);
				pMedia->getItemInfo(bstrName, &bstrValue);
				PRINTF(DEBUG_INFO, "WMPMEDIA", "Attribute %s - value %s", W2A(bstrName), W2A(bstrValue));
			}
            // Better check for local/streaming for the future
    		pMedia->getItemInfo(L"type", &bstrValue);
*/    		

			pMedia->getItemInfo(L"Author", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strArtist, SONG_INFO_FIELD_SIZE);
            pMedia->getItemInfo(L"Title", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strTrack, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"Album", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strAlbum, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"Genre", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strGenre, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"Comment", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strComment, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"SourceURL", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strFileName, SONG_INFO_FIELD_SIZE);
			
			pMedia->getItemInfo(L"Duration", &bstrValue);
			pSong->m_nLength = atoi(W2A(bstrValue));
			pMedia->getItemInfo(L"Track", &bstrValue);
			pSong->m_nTrackNo = atoi(W2A(bstrValue));
			pMedia->getItemInfo(L"Year", &bstrValue);
			pSong->m_nYear = atoi(W2A(bstrValue));
			
			bRet = TRUE;
		}	
	}

	return bRet;
}