#include <HiMusicMCI.h>
MusicMCI(音乐播放操作层)
支持播放、暂停、设置音量、获取播放时间等操作
在文件 HiMusicMCI.h 第 19 行定义.
◆ MusicMCI()
HiEasyX::MusicMCI::MusicMCI |
( |
| ) |
|
|
noexcept |
◆ ~MusicMCI()
HiEasyX::MusicMCI::~MusicMCI |
( |
| ) |
|
|
virtual |
◆ close()
bool HiEasyX::MusicMCI::close |
( |
| ) |
|
|
noexcept |
关闭音乐
在文件 HiMusicMCI.cpp 第 94 行定义.
96 MCI_GENERIC_PARMS mciGP{};
98 const DWORD dwReturn = mciSendCommand(nDeviceID, MCI_CLOSE,
99 MCI_NOTIFY | MCI_WAIT, (DWORD_PTR)(static_cast<LPVOID>(&mciGP)));
◆ getCurrentTime()
bool HiEasyX::MusicMCI::getCurrentTime |
( |
DWORD & |
pos | ) |
|
|
noexcept |
获取当前播放时间
在文件 HiMusicMCI.cpp 第 111 行定义.
113 MCI_STATUS_PARMS mciSP{};
115 mciSP.dwItem = MCI_STATUS_POSITION;
116 const DWORD dwReturn = mciSendCommand(nDeviceID, MCI_STATUS,
117 MCI_STATUS_ITEM, (DWORD_PTR)(static_cast<LPVOID>(&mciSP)));
120 pos = static_cast<DWORD>(mciSP.dwReturn);
◆ getTotalTime()
bool HiEasyX::MusicMCI::getTotalTime |
( |
DWORD & |
time | ) |
|
|
noexcept |
获取音乐总时长
在文件 HiMusicMCI.cpp 第 132 行定义.
134 MCI_STATUS_PARMS mciSP{};
136 mciSP.dwItem = MCI_STATUS_LENGTH;
137 const DWORD dwReturn = mciSendCommand(nDeviceID, MCI_STATUS,
138 MCI_WAIT | MCI_STATUS_ITEM, (DWORD_PTR)(static_cast<LPVOID>(&mciSP)));
141 time = static_cast<DWORD>(mciSP.dwReturn);
◆ open()
bool HiEasyX::MusicMCI::open |
( |
LPCWSTR |
music | ) |
|
|
noexcept |
打开音乐
在文件 HiMusicMCI.cpp 第 28 行定义.
32 mciOP.lpstrDeviceType =
nullptr;
33 mciOP.lpstrElementName = strSongPath;
34 const DWORD dwReturn = mciSendCommand(0, MCI_OPEN,
35 MCI_OPEN_ELEMENT | MCI_WAIT | MCI_OPEN_SHAREABLE, (DWORD_PTR)(static_cast<LPVOID>(&mciOP)));
40 nDeviceID = mciOP.wDeviceID;
◆ pause()
bool HiEasyX::MusicMCI::pause |
( |
| ) |
|
|
noexcept |
暂停音乐
在文件 HiMusicMCI.cpp 第 66 行定义.
68 MCI_GENERIC_PARMS mciGP{};
70 const DWORD dwReturn = mciSendCommand(nDeviceID, MCI_PAUSE,
71 MCI_NOTIFY | MCI_WAIT, (DWORD_PTR)(static_cast<LPVOID>(&mciGP)));
◆ play()
bool HiEasyX::MusicMCI::play |
( |
| ) |
|
|
noexcept |
播放音乐
在文件 HiMusicMCI.cpp 第 52 行定义.
54 MCI_PLAY_PARMS mciPP{};
56 const DWORD dwReturn = mciSendCommand(nDeviceID, MCI_PLAY,
57 MCI_NOTIFY, (DWORD_PTR)(static_cast<LPVOID>(&mciPP)));
◆ setStartTime()
bool HiEasyX::MusicMCI::setStartTime |
( |
size_t |
start | ) |
|
|
noexcept |
设置播放位置
在文件 HiMusicMCI.cpp 第 177 行定义.
182 if (start_time > end_time)
185 MCI_PLAY_PARMS mciPlay{};
186 mciPlay.dwFrom = static_cast<DWORD>(start_time);
187 mciPlay.dwTo = static_cast<DWORD>(end_time);
188 const DWORD dwReturn = mciSendCommand(nDeviceID, MCI_PLAY,
189 MCI_TO | MCI_FROM, (DWORD_PTR)(static_cast<LPVOID>(&mciPlay)));
◆ setVolume()
bool HiEasyX::MusicMCI::setVolume |
( |
size_t |
volume | ) |
|
|
noexcept |
设置音量大小
在文件 HiMusicMCI.cpp 第 153 行定义.
155 if (nVolumeValue > 1000)
159 else if (nVolumeValue < 0)
164 MCI_DGV_SETAUDIO_PARMS mciDSP;
165 mciDSP.dwItem = MCI_DGV_SETAUDIO_VOLUME;
166 mciDSP.dwValue = static_cast<DWORD>(nVolumeValue);
167 const DWORD dwReturn = mciSendCommand(nDeviceID, MCI_SETAUDIO,
168 MCI_DGV_SETAUDIO_VALUE | MCI_DGV_SETAUDIO_ITEM, (DWORD_PTR)(static_cast<LPVOID>(&mciDSP)));
◆ stop()
bool HiEasyX::MusicMCI::stop |
( |
| ) |
|
|
noexcept |
停止播放
在文件 HiMusicMCI.cpp 第 80 行定义.
82 MCI_SEEK_PARMS mciSP{};
84 const DWORD dwReturn = mciSendCommand(nDeviceID, MCI_SEEK,
85 MCI_WAIT | MCI_NOTIFY | MCI_SEEK_TO_START, (DWORD_PTR)(static_cast<LPVOID>(&mciSP)));
该类的文档由以下文件生成: