首页 > 代码库 > mciSendCommand 音频视频播放命令函数
mciSendCommand 音频视频播放命令函数
//打开设备
//typedef struct {
//DWORD dwCallback; //指定一个窗口句柄
//MCIDEVICEID wDeviceID; //为成功打开的文件返回 设备标识符.
//LPCSTR lpstrDeviceType; //设备类型的名字或常量标识. (设备名可以从注册表或者 SYSTEM.INI 文件中获得)
//LPCSTR lpstrElementName; //设备元素 (通常是打开的文件全路径).
//LPCSTR lpstrAlias//可选别名
//DWORD dwBufferSeconds;
//} MCI_WAVE_OPEN_PARMS;
//播放文件
//typedef struct {
//DWORD dwCallback;//指定一个窗口句柄
//DWORD dwFrom;//设置播放起始点
//DWORD dwTo;//设置播放结束点
//} MCI_PLAY_PARMS;
//查询信息
//typedef struct {
//DWORD dwCallback;
//DWORD dwReturn;//返回的信息内容
//DWORD dwItem;//请求查询的内容
//DWORD dwTrack;//轨道的长度或数目
//} MCI_STATUS_PARMS;
/*
* 函数名称:MCI_Open
* 函数介绍:用mci命令打开文件
* 输入参数:CString strPath, 文件的路径
* 输出参数:无
* 返回值 :mci命令的错误信息
*/
//typedef struct {
//DWORD dwCallback; //指定一个窗口句柄
//MCIDEVICEID wDeviceID; //为成功打开的文件返回 设备标识符.
//LPCSTR lpstrDeviceType; //设备类型的名字或常量标识. (设备名可以从注册表或者 SYSTEM.INI 文件中获得)
//LPCSTR lpstrElementName; //设备元素 (通常是打开的文件全路径).
//LPCSTR lpstrAlias//可选别名
//DWORD dwBufferSeconds;
//} MCI_WAVE_OPEN_PARMS;
//播放文件
//typedef struct {
//DWORD dwCallback;//指定一个窗口句柄
//DWORD dwFrom;//设置播放起始点
//DWORD dwTo;//设置播放结束点
//} MCI_PLAY_PARMS;
//查询信息
//typedef struct {
//DWORD dwCallback;
//DWORD dwReturn;//返回的信息内容
//DWORD dwItem;//请求查询的内容
//DWORD dwTrack;//轨道的长度或数目
//} MCI_STATUS_PARMS;
/*
* 函数名称:MCI_Open
* 函数介绍:用mci命令打开文件
* 输入参数:CString strPath, 文件的路径
* 输出参数:无
* 返回值 :mci命令的错误信息
*/
[cpp] view plain copy
print?
- DWORD dlg_login::MCIOpen(const CString &strPath)
- {
- //打开MCI设备
- MCI_OPEN_PARMS mciOP;
- DWORD opReturn;
- MCIDEVICEID wIDDevioce; //保存设备ID
- mciOP.lpstrDeviceType = NULL;
- mciOP.lpstrElementName = strPath; //设置打开的文件的名称
- opReturn = mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_ELEMENT, (DWORD)(LPVOID)&mciOP);
- if (opReturn == 0)
- {
- wIDDevioce = mciOP.wDeviceID;//播放设备Id
- wDevioceId = mciOP.wDeviceID;
- //设置设备信息
- MCI_SET_PARMS mciSet;
- mciSet.dwTimeFormat = MCI_FORMAT_MILLISECONDS; //设置时间单位为毫秒
- mciSendCommand(wDevioceId, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD)(LPVOID)&mciSet);
- //设置当前播放位置跳转60秒
- MCISeek(100);
- //音频播放
- MCIPlay();
- MCI_STATUS_PARMS mciStatus;
- mciStatus.dwItem = MCI_STATUS_TIME_FORMAT;
- DWORD sta2Return = mciSendCommand(wIDDevioce, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus);
- DWORD music_timestyle = mciStatus.dwReturn; //获得当前的时间格式
- mciStatus.dwItem = MCI_STATUS_MODE;
- DWORD sta3Return = mciSendCommand(wIDDevioce, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus);
- DWORD music_playstyle = mciStatus.dwReturn; //获得当前播放工作模式 播放 526 暂停525
- }
- else
- wIDDevioce = NULL;
- return opReturn;
- }
DWORD dlg_login::MCIOpen(const CString &strPath) { //打开MCI设备 MCI_OPEN_PARMS mciOP; DWORD opReturn; MCIDEVICEID wIDDevioce; //保存设备ID mciOP.lpstrDeviceType = NULL; mciOP.lpstrElementName = strPath; //设置打开的文件的名称 opReturn = mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_ELEMENT, (DWORD)(LPVOID)&mciOP); if (opReturn == 0) { wIDDevioce = mciOP.wDeviceID;//播放设备Id wDevioceId = mciOP.wDeviceID; //设置设备信息 MCI_SET_PARMS mciSet; mciSet.dwTimeFormat = MCI_FORMAT_MILLISECONDS; //设置时间单位为毫秒 mciSendCommand(wDevioceId, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD)(LPVOID)&mciSet); //设置当前播放位置跳转60秒 MCISeek(100); //音频播放 MCIPlay(); MCI_STATUS_PARMS mciStatus; mciStatus.dwItem = MCI_STATUS_TIME_FORMAT; DWORD sta2Return = mciSendCommand(wIDDevioce, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus); DWORD music_timestyle = mciStatus.dwReturn; //获得当前的时间格式 mciStatus.dwItem = MCI_STATUS_MODE; DWORD sta3Return = mciSendCommand(wIDDevioce, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus); DWORD music_playstyle = mciStatus.dwReturn; //获得当前播放工作模式 播放 526 暂停525 } else wIDDevioce = NULL; return opReturn; }
[cpp] view plain copy
print?
- DWORD dlg_login::MCIPlay()
- {
- MCI_PLAY_PARMS mciPP;
- DWORD opReturn;
- opReturn = mciSendCommand(wDevioceId, MCI_PLAY, MCI_NOTIFY, (DWORD)&mciPP);
- return opReturn;
- }
DWORD dlg_login::MCIPlay() { MCI_PLAY_PARMS mciPP; DWORD opReturn; opReturn = mciSendCommand(wDevioceId, MCI_PLAY, MCI_NOTIFY, (DWORD)&mciPP); return opReturn; }
[cpp] view plain copy
print?
- DWORD dlg_login::MCIStatus_music_length()
- {
- MCI_STATUS_PARMS mciStatus;
- mciStatus.dwItem = MCI_STATUS_LENGTH;
- DWORD staReturn = mciSendCommand(wDevioceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus);
- DWORD music_alltime = mciStatus.dwReturn / 1000; //音乐总时间
- return music_alltime;
- }
DWORD dlg_login::MCIStatus_music_length() { MCI_STATUS_PARMS mciStatus; mciStatus.dwItem = MCI_STATUS_LENGTH; DWORD staReturn = mciSendCommand(wDevioceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus); DWORD music_alltime = mciStatus.dwReturn / 1000; //音乐总时间 return music_alltime; }
[cpp] view plain copy
print?
- DWORD dlg_login::MCIStatus_music_pos()
- {
- MCI_STATUS_PARMS mciStatus;
- mciStatus.dwItem = MCI_STATUS_POSITION;
- DWORD sta1Return = mciSendCommand(wDevioceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus);
- DWORD music_timeing = mciStatus.dwReturn / 1000; //音乐当前播放时间
- return music_timeing;
- }
DWORD dlg_login::MCIStatus_music_pos() { MCI_STATUS_PARMS mciStatus; mciStatus.dwItem = MCI_STATUS_POSITION; DWORD sta1Return = mciSendCommand(wDevioceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus); DWORD music_timeing = mciStatus.dwReturn / 1000; //音乐当前播放时间 return music_timeing; }
[cpp] view plain copy
print?
- //从制定位置开始播放
- void send_music_from_pos()
- {
- MCI_STATUS_PARMS mciStatus;
- mciStatus.dwItem = MCI_STATUS_POSITION;
- DWORD sta1Return = mciSendCommand(wDevioceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus);
- DWORD music_timeing = mciStatus.dwReturn / 1000; //音乐当前播放时间
- MCI_PLAY_PARMS PlayParms;
- PlayParms.dwFrom = music_timeing; // 指定从什么地方(时间)播放
- DWORD ret1 = mciSendCommand(wDevioceId, MCI_PLAY, MCI_NOTIFY, (DWORD)(LPVOID)&PlayParms);
- }
//从制定位置开始播放 void send_music_from_pos() { MCI_STATUS_PARMS mciStatus; mciStatus.dwItem = MCI_STATUS_POSITION; DWORD sta1Return = mciSendCommand(wDevioceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus); DWORD music_timeing = mciStatus.dwReturn / 1000; //音乐当前播放时间 MCI_PLAY_PARMS PlayParms; PlayParms.dwFrom = music_timeing; // 指定从什么地方(时间)播放 DWORD ret1 = mciSendCommand(wDevioceId, MCI_PLAY, MCI_NOTIFY, (DWORD)(LPVOID)&PlayParms); }
//关闭指定设备
[cpp] view plain copy
print?
- void close_mci()
- {
- DWORD retclose=mciSendCommand(wDevioceId, MCI_CLOSE, NULL, NULL);
- }
void close_mci() { DWORD retclose=mciSendCommand(wDevioceId, MCI_CLOSE, NULL, NULL); }
[cpp] view plain copy
print?
- //调节音量
- DWORD dlg_login::MCISetVolume(DWORD dwVol)
- {
- MCI_DGV_SETAUDIO_PARMS mciSetAudioPara;
- mciSetAudioPara.dwCallback = NULL;
- mciSetAudioPara.dwItem = MCI_DGV_SETAUDIO_VOLUME;
- mciSetAudioPara.dwValue = dwVol; //此处就是音量大小 (0--1000)
- DWORD dwReturn = mciSendCommand(wDevioceId, MCI_SETAUDIO, MCI_DGV_SETAUDIO_VALUE | MCI_DGV_SETAUDIO_ITEM, (DWORD)(LPVOID)&mciSetAudioPara);
- return dwReturn;
- }
//调节音量 DWORD dlg_login::MCISetVolume(DWORD dwVol) { MCI_DGV_SETAUDIO_PARMS mciSetAudioPara; mciSetAudioPara.dwCallback = NULL; mciSetAudioPara.dwItem = MCI_DGV_SETAUDIO_VOLUME; mciSetAudioPara.dwValue = http://www.mamicode.com/dwVol; //此处就是音量大小 (0--1000)>
jpg改rar
mciSendCommand 音频视频播放命令函数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。