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; }
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; }
void PlayListMgr::AddSongToList(spSongInfoT spSong,unsigned int u_listId) { ASSERT(spSong); CSongInfo songInfo; songInfo.SetAblumName(spSong->GetAlbumName()); songInfo.SetAddTime(spSong->GetAddTime()); songInfo.SetAlbumId(spSong->GetAlbumId()); songInfo.SetArtistId(spSong->GetArtistId()); songInfo.SetArtistName(spSong->GetArtistName()); songInfo.SetAudioLength(spSong->GetAudioLength()); songInfo.SetCoverLocalPath(spSong->GetCoverLocalPath()); songInfo.SetCoverUrl(spSong->GetCoverUrl()); songInfo.SetEnable(spSong->IsEnable()); songInfo.SetFileExt(spSong->GetFileExt()); songInfo.SetFileSize(spSong->GetFileSize()); songInfo.SetFileStartPos(spSong->GetFileStartPos()); songInfo.SetFileType(spSong->GetFileType()); songInfo.SetFlag(spSong->GetFlag()); songInfo.SetLastModifyTime(spSong->GetLastModifyTime()); songInfo.SetLastPlayTime(spSong->GetLastPlayTime()); songInfo.SetListenFileUrl(spSong->GetListenFileUrl()); songInfo.SetLocal(spSong->IsLocal()); songInfo.SetLocalId(spSong->GetLocalId()); songInfo.SetLocalPath(spSong->GetLocalPath()); songInfo.SetLrcLocalPath(spSong->GetLrcLocalPath()); songInfo.SetLrcUrl(spSong->GetLrcUrl()); songInfo.SetMD5(spSong->GetMD5()); songInfo.SetPlayCount(spSong->GetPlayCount()); songInfo.SetRealArtistName(spSong->GetRealArtistName()); songInfo.SetResourceID(spSong->GetResourceId()); songInfo.SetSongId(spSong->GetSongId()); songInfo.SetSongName(spSong->GetSongName()); songInfo.SetTag(spSong->GetTag()); AddSongToList(songInfo,u_listId); }
void CPlayCenter::GetAllPlayList() { RemoveAllList(); if (theRuntimeState->GetLogUserInfo()) { theDbMgr->SetCurrentUser(theRuntimeState->GetLogUserInfo()); } { std::vector<spPlayListInfoT> PlayList; theDbMgr->GetUserDB()->GetAllPlayLists(PlayList); for (auto it=PlayList.begin();it!=PlayList.end();++it) { CPlayListInfo playList; playList.SetComment((*it)->GetComment()); playList.SetFlag((*it)->GetFlag()); playList.SetId((*it)->GetId()); playList.SetListType((*it)->GetListType()); playList.SetLocalId((*it)->GetLocalId()); playList.SetName((*it)->GetName()); playList.SetShow((*it)->IsShow()); playList.SetTag((*it)->GetTag()); AddPlayList(playList); std::vector<spSongInfoT> SongList; theDbMgr->GetUserDB()->GetPlayListSongs(SongList,(*it)->GetLocalId()); for (auto it2=SongList.begin();it2!=SongList.end();++it2) { CSongInfo songInfo; songInfo.SetAblumName((*it2)->GetAlbumName()); songInfo.SetAddTime((*it2)->GetAddTime()); songInfo.SetAlbumId((*it2)->GetAlbumId()); songInfo.SetArtistId((*it2)->GetArtistId()); songInfo.SetArtistName((*it2)->GetArtistName()); songInfo.SetAudioLength((*it2)->GetAudioLength()); songInfo.SetCoverLocalPath((*it2)->GetCoverLocalPath()); songInfo.SetCoverUrl((*it2)->GetCoverUrl()); songInfo.SetEnable((*it2)->IsEnable()); songInfo.SetFileExt((*it2)->GetFileExt()); songInfo.SetFileSize((*it2)->GetFileSize()); songInfo.SetFileStartPos((*it2)->GetFileStartPos()); songInfo.SetFileType((*it2)->GetFileType()); songInfo.SetFlag((*it2)->GetFlag()); songInfo.SetLastModifyTime((*it2)->GetLastModifyTime()); songInfo.SetLastPlayTime((*it2)->GetLastPlayTime()); songInfo.SetListenFileUrl((*it2)->GetListenFileUrl()); songInfo.SetLocal((*it2)->IsLocal()); songInfo.SetLocalId((*it2)->GetLocalId()); songInfo.SetLocalPath((*it2)->GetLocalPath()); songInfo.SetLrcLocalPath((*it2)->GetLrcLocalPath()); songInfo.SetLrcUrl((*it2)->GetLrcUrl()); songInfo.SetMD5((*it2)->GetMD5()); songInfo.SetPlayCount((*it2)->GetPlayCount()); songInfo.SetRealArtistName((*it2)->GetRealArtistName()); songInfo.SetResourceID((*it2)->GetResourceId()); songInfo.SetSongId((*it2)->GetSongId()); songInfo.SetSongName((*it2)->GetSongName()); songInfo.SetTag((*it2)->GetTag()); AddSongToList(songInfo,(*it)->GetLocalId()); } } } }