最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

使用windows API播放声音文件(wav、mp3)等

业界 admin 7浏览 0评论

软件:

     vs2010

工程:

    控制台程序(空工程)


代码如下:

/*
mciSendCommand播放音乐,调用简单,功能强大,但是它只能同时播放一个
文件,而有的项目中需要同时播放几个文件,实现混音效果,这时就要使用
DirectSound或者其它库或技术了!
*/
#include <Windows.h>
#include <MMSystem.h>
#include <map>
#include <iostream>
using namespace std;
#pragma comment(lib, "WINMM.LIB")


void PlayBeep()
{
Beep(3000,500);
}


void PlaySysMusic()
{
MessageBeep(MB_OK);  
Sleep(800);  
MessageBeep(MB_ICONWARNING);  
Sleep(800);  
MessageBeep(MB_ICONSTOP);  
Sleep(800);  
MessageBeep(MB_ICONERROR);  
Sleep(800);  
MessageBeep(MB_ICONEXCLAMATION); 
}


void PlayWavMusic()
{
PlaySound("GAME_WIN.WAV",NULL/*AfxGe

软件:

     vs2010

工程:

    控制台程序(空工程)


代码如下:

/*
mciSendCommand播放音乐,调用简单,功能强大,但是它只能同时播放一个
文件,而有的项目中需要同时播放几个文件,实现混音效果,这时就要使用
DirectSound或者其它库或技术了!
*/
#include <Windows.h>
#include <MMSystem.h>
#include <map>
#include <iostream>
using namespace std;
#pragma comment(lib, "WINMM.LIB")


void PlayBeep()
{
Beep(3000,500);
}


void PlaySysMusic()
{
MessageBeep(MB_OK);  
Sleep(800);  
MessageBeep(MB_ICONWARNING);  
Sleep(800);  
MessageBeep(MB_ICONSTOP);  
Sleep(800);  
MessageBeep(MB_ICONERROR);  
Sleep(800);  
MessageBeep(MB_ICONEXCLAMATION); 
}


void PlayWavMusic()
{
PlaySound("GAME_WIN.WAV",NULL/*AfxGe

发布评论

评论列表 (0)

  1. 暂无评论