#include "QMPlayModelManager.h"
#include <QTime>
#include <map>
using namespace std;
#include "QMPublic.h"
#include "QMAppHelper.h"
#include "QMDataManager.h"
#include "QMAudioDriverManager.h"
#include "QMListWindow.h"
#include "QMMusicListView.h"
#include "QMTrack.h"
#include "QMMusic.h"
#include "QMPlayModelManagerListener.h"
#include "QMDataDispatcher.h"
typedef map<QMPlayModelManager::PlayModel, PlayModelFun> Map_PlayModelFun;
typedef pair<QMPlayModelManager::PlayModel, PlayModelFun> MapPair_PlayModelFun;
static Map_PlayModelFun g_mapPlayModeFun;
QMPlayModelManager::QMPlayModelManager(void)
: m_pModelFun(NULL)
, m_bBeginPlay(false)
, m_pCurrTrack(NULL)
, m_pCurrMusic(NULL)
, m_pSelectTrack(NULL)
, m_pSelectMusic(NULL)
, m_pModelListener(NULL)
{
}
QMPlayModelManager::~QMPlayModelManager(void)
{
}
bool QMPlayModelManager::Init()
{
bool bResult = false;
m_pModelListener = new QMPlayModelManagerListener(this);
QM_CHECK_ERROR(m_pModelListener);
QMDataDispatcher* pDataDispatcher = QMAppHelper::GetDataDispatcher();
QM_PROCESS_ERROR(pDataDispatcher);
QM_PROCESS_ERROR(pDataDispatcher->AddListener(m_pModelListener));
m_pModelFun = &QMPlayModelManager::SetModel_Other;
g_mapPlayModeFun.insert(MapPair_PlayModelFun(Other, &QMPlayModelManager::SetModel_Other));
g_mapPlayModeFun.insert(MapPair_PlayModelFun(Random, &QMPlayModelManager::SetModel_Random));
g_mapPlayModeFun.insert(MapPair_PlayModelFun(Circulation, &QMPlayModelManager::SetModel_Circulation));
bResult = true;
Exit0:
return bResult;
}
bool QMPlayModelManager::UnInit()
{
bool bResult = false;
SAFE_DELETE(m_pModelListener);
bResult = true;
Exit0:
return bResult;
}
bool QMPlayModelManager::SetPlayModel(PlayModel model)
{
bool bResult = false;
Map_PlayModelFun::iterator iter;
QM_PROCESS_ERROR(g_mapPlayModeFun.size() != 0);
iter = g_mapPlayModeFun.find(model);
QM_PROCESS_ERROR(iter != g_mapPlayModeFun.end());
m_pModelFun = iter->second;
QM_PROCESS_ERROR(m_pModelFun);
bResult = true;
Exit0:
return bResult;
}
bool QMPlayModelManager::CheckToPlayNext()
{
bool bResult = false;
QM_PROCESS_SUCCESS(!m_bBeginPlay);
QMAudioDriverManager* pAudioManager = QMAppHelper::GetAudioDriverManager();
QM_PROCESS_ERROR(pAudioManager);
QM_PROCESS_SUCCESS(pAudioManager->IsCurrAudio_Play());
QM_PROCESS_ERROR(m_pModelFun);
QM_PROCESS_ERROR((this->*m_pModelFun)());
Exit1:
bResult = true;
Exit0:
return bResult;
}
bool QMPlayModelManager::PlaySelectMusic()
{
bool bResult = false;
QM_PROCESS_SUCCESS(!m_pSelectMusic || !m_pSelectTrack);
QM_PROCESS_ERROR(PlayMusic(m_pSelectTrack, m_pSelectMusic));
Exit1:
bResult = true;
Exit0:
return true;
}
bool QMPlayModelManager::PlayCurrMusic()
{
bool bResult = false;
QM_PROCESS_SUCCESS(!m_pCurrMusic && !m_pCurrTrack);
QM_PROCESS_ERROR(PlayMusic(m_pCurrTrack, m_pCurrMusic));
Exit1:
bResult = true;
Exit0:
return true;
}
QMPlayModelManager::PlayModel QMPlayModelManager::GetCurrModel()
{
PlayModel enumModel = PlayModel::Other;
Map_PlayModelFun::iterator iter = g_mapPlayModeFun.begin();
QM_PROCESS_ERROR(m_pModelFun);
for(iter; iter != g_mapPlayModeFun.end(); iter++)
{
if(iter->second == m_pModelFun)
break;
}
enumModel = iter->first;
Exit0:
return enumModel;
}
QMPlayModelManager::PlayModel QMPlayModelManager::SetNextMode()
{
PlayModel enumModel = GetCurrModel();
Map_PlayModelFun::iterator iter = g_mapPlayModeFun.find(enumModel);
iter++;
if(iter == g_mapPlayModeFun.end())
iter = g_mapPlayModeFun.begin();
enumModel = iter->first;
m_pModelFun = iter->second;
Exit0:
return enumModel;
}
bool QMPlayModelManager::SetSelectTrackRow(int nRow)
{
return SetTrackRow(&m_pSelectTrack, nRow);
}
int QMPlayModelManager::GetSelectTrackRow()
{
return GetTrackRow(m_pSelectTrack);
}
bool QMPlayModelManager::SetSelectMusicRow(int nRow)
{
return SetMusicRow(m_pSelectTrack, &m_pSelectMusic, nRow);
}
int QMPlayModelManager::GetSelectMusicRow()
{
return GetMusicRow(m_pSelectTrack, m_pSelectMusic);
}
bool QMPlayModelManager::SetCurrTrackRow(int nRow)
{
return SetTrackRow(&m_pCurrTrack, nRow);
}
int QMPlayModelManager::GetCurrTrackRow()
{
return GetTrackRow(m_pCurrTrack);
}
bool QMPlayModelManager::SetCurrMusicRow(int nRow)
{
return SetMusicRow(m_pCurrTrack, &m_pCurrMusic, nRow);
}
int QMPlayModelManager::GetCurrMusicRow()
{
return GetMusicRow(m_pCurrTrack, m_pCurrMusic);
}
bool QMPlayModelManager::PlayMusic(QMTrack* pTrack, QMMusic* pMusic)
{
bool bResult = false;
m_bBeginPlay = true;
QM_PROCESS_ERROR(pTrack && pMusic);
QMAudioDriverManager* pAudioManager = QMAppHelper::GetAudioDriverManager();
QM_PROCESS_ERROR(pAudioManager);
m_pCurrMusic = pMusic;
m_pCurrTrack = pTrack;
QM_PROCESS_ERROR(pAudioManager->StopCurrAudio());
QM_PROCESS_ERROR(pAudioManager->InitAudio(pMusic->m_qstrPath));
QM_PROCESS_ERROR(pAudioManager->PlayAudio(pMusic->m_qstrPath));
QMListWindow* pListWindow = QMAppHelper::GetListWindow();
QM_PROCESS_ERROR(pListWindow);
QM_PROCESS_ERROR(pListWindow->GetMusicListView()->Reflash());
bResult = true;
Exit0:
return bResult;
}
bool QMPlayModelManager::SetTrackRow(QMTrack** pTrack, int nRow)
{
bool bResult = false;
*pTrack = NULL;
QMDataManager *pDataManager = QMAppHelper::GetDataManager();
QM_PROCESS_ERROR(pDataManager);
QM_PROCESS_ERROR_NO_WARNING(nRow >= 0 && nRow < pDataManager->GetTrackCount());
*pTrack = pDataManager->GetTrack(nRow);
QM_PROCESS_ERROR(pTrack);
bResult = true;
Exit0:
return bResult;
}
int QMPlayModelManager::GetTrackRow(QMTrack* pTrack)
{
int nRow = -1;
QMDataManager *pDataManager = QMAppHelper::GetDataManager();
QM_PROCESS_ERROR(pDataManager);
QM_PROCESS_ERROR_NO_WARNING(pDataManager->GetTrackCount() != 0);
QM_PROCESS_ERROR_NO_WARNING(pTrack);
nRow = pDataManager->FindTrackRow(pTrack);
Exit0:
return nRow;
}
bool QMPlayModelManager::SetMusicRow(QMTrack* pTrack, QMMusic** pMusic, int nRow)
{
bool bResult = false;
*pMusic = NULL;
QM_PROCESS_ERROR(pTrack);
QMDataManager *pDataManager = QMAppHelper::GetDataManager();
QM_PROCESS_ERROR(pDataManager);
QM_PROCESS_ERROR_NO_WARNING(nRow >= 0 && nRow < pDataManager->GetMusicCount(pTrack));
*pMusic = pTrack->GetMusic(nRow);
QM_PROCESS_ERROR(pMusic);
bResult = true;
Exit0:
return bResult;
}
int QMPlayModelManager::GetMusicRow(QMTrack* pTrack, QMMusic* pMuisc)
{
int nRow = -1;
QM_PROCESS_ERROR_NO_WARNING(pTrack && pMuisc);
QMDataManager *pDataManager = QMAppHelper::GetDataManager();
QM_PROCESS_ERROR(pDataManager);
QM_PROCESS_ERROR_NO_WARNING(pDataManager->GetTrackCount() != 0);
nRow = pTrack->FindMusicRow(pMuisc);
Exit0:
return nRow;
}
bool QMPlayModelManager::SetModel_Other()
{
bool bResult = false;
int nRow = 0;
QMDataManager* pDataManager = QMAppHelper::GetDataManager();
QM_PROCESS_ERROR(pDataManager);
nRow = GetCurrMusicRow();
QM_PROCESS_SUCCESS(nRow < 0);
QM_PROCESS_SUCCESS(nRow == (pDataManager->GetMusicCount(m_pCurrTrack) - 1));
QM_PROCESS_ERROR(SetCurrMusicRow(nRow + 1));
QM_PROCESS_ERROR(m_pCurrTrack && m_pCurrMusic);
QM_PROCESS_ERROR(PlayMusic(m_pCurrTrack, m_pCurrMusic));
Exit1:
bResult = true;
Exit0:
return bResult;
}
bool QMPlayModelManager::SetModel_Random()
{
bool bResult = false;
int nCurrRow = 0, nRow = 0;
QMDataManager* pDataManager = QMAppHelper::GetDataManager();
QM_PROCESS_ERROR(pDataManager);
nCurrRow = GetCurrMusicRow();
QM_PROCESS_SUCCESS(nCurrRow < 0);
do
{
QTime qtime = QTime::currentTime();
qsrand(qtime.msec() + qtime.second()*1000);
nRow = qrand() % pDataManager->GetMusicCount(m_pCurrTrack);
}
while (nCurrRow == nRow);
QM_PROCESS_ERROR(SetCurrMusicRow(nRow));
QM_PROCESS_
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
QT 简易音乐播放器 FMod (127个子文件)
QMPlayModelManager.cpp 8KB
QMAudioDriver_Fmod.cpp 8KB
QMListWindow.cpp 7KB
QMusierWindow.cpp 6KB
moc_QMSlotsForMainWindow.cpp 6KB
moc_QMSlotsForMainWindow.cpp 6KB
QMDataLibrary.cpp 6KB
QMMusicListView.cpp 6KB
QMSlotsForMainWindow.cpp 6KB
QMDataManager.cpp 5KB
moc_QMSlotForListWindow.cpp 4KB
moc_QMSlotForListWindow.cpp 4KB
moc_QMSlotsForMusicListView.cpp 4KB
moc_QMSlotsForMusicListView.cpp 4KB
moc_QMSlotsForTrackListView.cpp 4KB
moc_QMSlotsForTrackListView.cpp 4KB
QMMusicListModel.cpp 4KB
QMTrackListView.cpp 4KB
QMAudioDriverManager.cpp 4KB
QMTrackListModel.cpp 3KB
moc_QMMusicListView.cpp 3KB
moc_QMMusicListView.cpp 3KB
moc_QMTrackListView.cpp 3KB
moc_QMTrackListView.cpp 3KB
moc_QMusierWindow.cpp 3KB
moc_QMusierWindow.cpp 3KB
moc_QMListWindow.cpp 3KB
moc_QMListWindow.cpp 3KB
QMTrack.cpp 3KB
QMDataDispatcher.cpp 2KB
QMSlotsForMusicListView.cpp 2KB
QMAppHelper.cpp 2KB
main.cpp 2KB
QMSlotForListWindow.cpp 2KB
QMPlayModelManagerListener.cpp 2KB
QMListWindowListener.cpp 2KB
QMWinMoveFilter.cpp 1KB
QMSlotsForTrackListView.cpp 1KB
qrc_mainWindow.cpp 692B
QMMusic.cpp 368B
icudt51.dll 21.28MB
Qt5Cored.dll 7.91MB
Qt5Widgetsd.dll 7.69MB
Qt5Guid.dll 5.91MB
libGLESv2d.dll 2.58MB
fmod.dll 2.06MB
icuin51.dll 1.72MB
icuuc51.dll 1.27MB
libEGLd.dll 247KB
QMusier.vcxproj.filters 13KB
fmod_common.h 99KB
fmod_dsp.h 63KB
fmod.h 47KB
fmod_errors.h 15KB
fmod_memoryinfo.h 14KB
fmod_codec.h 13KB
ui_MainWindow.h 8KB
fmod_output.h 7KB
ui_listWindow.h 4KB
QMPublic.h 2KB
QMPlayModelManager.h 1KB
QMAudioDriverManager.h 1KB
QMAudioDriver_Fmod.h 1KB
QMAppHelper.h 1KB
QMMusicListView.h 1KB
QMDataManager.h 1KB
QMListWindow.h 1KB
QMDataLibrary.h 976B
QMSlotsForMainWindow.h 955B
QMTrackListView.h 921B
QMDataDispatcher.h 855B
IAudioDriver.h 806B
QMusierWindow.h 771B
QMTrackListModel.h 734B
QMListWindowListener.h 701B
QMTrack.h 673B
QMMusicListModel.h 668B
QMSlotForListWindow.h 539B
IDataListeners.h 520B
QMSlotsForMusicListView.h 515B
QMWinMoveFilter.h 461B
QMSlotsForTrackListView.h 461B
QMPlayModelManagerListener.h 448B
QMMusic.h 241B
fmod.hpp 36KB
musier.ico 9KB
fmodL_vc.lib 243KB
fmod_vc.lib 242KB
fmodL64_vc.lib 240KB
fmod64_vc.lib 240KB
main_background.png 535KB
list_background.png 248KB
btn_addMusic1.png 180KB
btn_stop1.png 180KB
btn_pause1.png 151KB
btn_close1.png 118KB
btn_close1.png 118KB
btn_play1.png 115KB
btn_deleteMusic1.png 115KB
btn_list1.png 99KB
共 127 条
- 1
- 2
资源评论
- /ycc2020-11-03不会用,没有.pro文件我咋打开呀,库还是vc的
- chengxizhinishiyituo2018-03-18不是纯qt的_(:з」∠)_ 并不是我需要的那种 不过还算是有点帮助
hardie蚊子
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功