예제 #1
0
spSongInfoT CPlayCenter::ParaseFromPath(CString sPath)
{
	CSongInfo spSong;
	TStreamFormat tf = GetFileFormat(sPath);
	if (tf==TStreamFormat::sfUnknown)
	{
//		byte bb[128]={0};
//		YTing::CMp3FileInfo::Mp3Info mp3 = YTing::CMp3FileInfo::getMp3Info(sPath,bb);
	}
	
	TID3InfoExW tid3;
	ZeroMemory(&tid3,sizeof(tid3));
	spSong.SetLocalPath(sPath);
	spSong.SetLocal(true);
	spSong.SetAddTime(mci::now_time());
	spSong.SetFileSize(mci::get_file_size(sPath));
	spSong.SetFileStartPos(0);
	if(LoadFileInfo2(sPath,&tid3))
	{	
		spSong.SetArtistName((tid3.Artist));
		spSong.SetSongName(tid3.Title);
		spSong.SetAblumName(tid3.Album);
		spSong.SetFileExt(mci::rip_file_ext(sPath,true));
		spSong.SetRealArtistName(tid3.AlbumArtist);		
		spSong.SetEnable(true);		
	}
	spSongInfoT spSongInfo = spSongInfoT(new CSongInfo(spSong));
	CheckSong(spSongInfo);
	return spSongInfo;
}
예제 #2
0
spSongInfoT PlayListMgr::PraseFromPath(LPCTSTR path)
{
	ASSERT(path);
	spSongInfoT spSong;
	CSongInfo song;
	AudioTagInfo * ptagInfo = new AudioTagInfo;
	ptagInfo->init(mci::unicode_2_ansi(path));

	song.SetSongName(mci::ansi_2_CString(ptagInfo->title().c_str()));
	if (song.GetSongName().IsEmpty())
	{
		song.SetSongName(mci::rip_file_name(path,false));
	}
	song.SetAblumName(mci::ansi_2_CString(ptagInfo->album().c_str()));
	song.SetArtistName(mci::ansi_2_CString(ptagInfo->artist().c_str()));
	song.SetLocalPath(path);
	song.SetLocal(true);
	song.SetAddTime(mci::now_time());
	song.SetFileSize(mci::get_file_size(path));
	song.SetFileStartPos(0);
	song.SetFileExt(mci::rip_file_ext(path,true));
	song.SetRealArtistName(mci::ansi_2_CString(ptagInfo->artist().c_str()));		
	song.SetEnable(true);

	spSong = spSongInfoT(new CSongInfo(song));

	delete ptagInfo;

	return spSong;
}
예제 #3
0
spSongInfoT PlayListMgr::GetSongInfo(unsigned int u_songId,unsigned int u_listId)
{
	playListSongMapIterT itEnd = m_spSongListMap.end();
	playListSongMapIterT itFind = m_spSongListMap.find(u_listId);
	ASSERT(itEnd != itFind);
	spSongInfoT spSong;
	const songsArrayT& songList = itFind->second;
	for (auto iter=songList.begin();iter!=songList.end();++iter)
	{
		if(iter->GetLocalId()==u_listId)
		{
			CSongInfo song = *iter;
			spSong = spSongInfoT(&song);
			return spSong;
		}
	}

	return spSong;
}
예제 #4
0
spSongInfoT CPlayCenter::GetCurrentPlayingSong()
{
	spSongInfoT spSongInfo;
	if(m_spPlayList.size()==0||m_spSongListMap.size()==0) return spSongInfo;
	if(m_spPlayList.find(m_iCurPlayingListIndex)==m_spPlayList.end()) return spSongInfo;
	auto iter = m_spSongListMap.find(m_iCurPlayingListIndex);
	if (iter!=m_spSongListMap.end())
	{
		songsArrayT songs = iter->second;
		if(songs.size()>0)
		{
			for (songsArrayIterT iter=songs.begin();iter!=songs.end();++iter)
			{
				if(iter->GetLocalId()==m_iCurPlayingSongIndex)
				{
					spSongInfo = spSongInfoT(new CSongInfo(*iter));
					break;
				}
			}
		}
	}
	return spSongInfo;
}
예제 #5
0
void PlayListMgr::Reset()
{
	m_spSongListMap.clear();
	m_spCurSong = spSongInfoT(NULL);
	m_spCurList = spPlayListInfoT(NULL);
}
예제 #6
0
spSongInfoT PlayListMgr::GetPrevSongToPlay()
{
	spSongInfoT spSong;
	if(!m_spCurList)
	{
		SetCurSong(spSong);
		return spSong;
	}

	auto it = m_spSongListMap.find(m_spCurList->GetLocalId());
	if (it != m_spSongListMap.end())
	{
		const songsArrayT& songList = it->second;
		const size_t nSize = songList.size();
		if (nSize<=0)
		{//列表没有歌曲
			SetCurSong(spSong);
			return spSong;
		}
		switch (m_playMode)
		{
		case EM_LIST_ORDER://顺序播放
			{
				if (!m_spCurSong)
				{
					const CSongInfo& songInfo = songList[0];
					spSong = spSongInfoT(new CSongInfo(songInfo));
					SetCurSong(spSong);
					return spSong;
				}
				else
				{
					int nIndex = GetCurIndexByCurSong(songList);
					nIndex --;
					if (nIndex>=0)
					{
						const CSongInfo& songInfo = songList[nIndex];
						spSong = spSongInfoT(new CSongInfo(songInfo));
						SetCurSong(spSong);
						return spSong;
					}
					else
					{
						SetCurSong(spSong);
						return spSong;
					}					
				}
			}
		case EM_LIST_LOOP://列表循环
			{
				if (!m_spCurSong)
				{
					const CSongInfo& songInfo = songList[0];
					spSong = spSongInfoT(new CSongInfo(songInfo));
					SetCurSong(spSong);
					return spSong;
				}
				else
				{
					int nIndex = GetCurIndexByCurSong(songList);
					nIndex --;
					if (nIndex>=0)
					{
						const CSongInfo& songInfo = songList[nIndex];
						spSong = spSongInfoT(new CSongInfo(songInfo));					
					}
					else
					{
						const CSongInfo& songInfo = songList[nSize-1];
						spSong = spSongInfoT(new CSongInfo(songInfo));
					}
					SetCurSong(spSong);
					return spSong;
				}
			}
		case EM_SINGLE_LOOP://单曲循环
			{
				int nIndex = 0;
				if (!m_spCurSong)
				{
					nIndex = 0;
				}
				else
				{
					nIndex = GetCurIndexByCurSong(songList);					
				}
				const CSongInfo& songInfo = songList[nIndex];
				spSong = spSongInfoT(new CSongInfo(songInfo));
				SetCurSong(spSong);
				return spSong;
			}
		case EM_RAMDON://随机播放
			{
				if (! m_spRandomId.size())
				{
					MakeRandId(songList.size());
				}

				int nIndex = m_spRandomId.front();
				m_spRandomId.pop_front();

				const CSongInfo& songInfo = songList[nIndex];
				spSong = spSongInfoT(new CSongInfo(songInfo));
				SetCurSong(spSong);
				return spSong;
			}
		}	
	}
	SetCurSong(spSong);
	return spSong;
}