c语言编写的程序播放背景音乐
发布网友
发布时间:2022-04-23 16:35
我来回答
共3个回答
热心网友
时间:2023-10-09 12:41
用windows CE里面播放音乐的库函数:
This function plays a single waveform sound. To play multiple sounds simultaneously, use the waveOut* functions in the Waveform Audio API.
BOOL sndPlaySound(
LPCTSTR lpszSoundName,
UINT fuSound
);
Parameters
lpszSoundName
Long pointer to a null-terminated string that specifies the sound to play. This parameter can be either an entry in the registry or in WIN.INI that identifies a system sound, or it can be the name of a waveform-audio file. (If the function does not find the entry, the parameter is treated as a file name.) If this parameter is NULL, any currently playing sound is stopped.
fuSound
Flags for playing the sound. The following table shows the possible values. Value Description
SND_ALIAS The pszSound parameter is a system-event alias in the registry or the WIN.INI file. Do not use with either SND_FILENAME or SND_RESOURCE.
SND_ASYNC The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
SND_FILENAME The pszSound parameter is a file name.
SND_LOOP The sound plays repeatedly until PlaySound is called again with the pszSound parameter set to NULL. You must also specify the SND_ASYNC flag to indicate an asynchronous sound event.
SND_MEMORY A sound event's file is loaded in RAM. The parameter specified by pszSound must point to an image of a sound in memory.
SND_NODEFAULT No default sound event is used. If the sound cannot be found, PlaySound returns silently without playing the default sound.
SND_NOSTOP The specified sound event will yield to another sound event that is already playing. If a sound cannot be played because the resource needed to generate that sound is busy playing another sound, the function immediately returns FALSE without playing the requested sound.
If this flag is not specified, PlaySound attempts to stop the currently playing sound so that the device can be used to play the new sound.
SND_SYNC Synchronous playback of a sound event. PlaySound returns after the sound event completes.
Return Values
TRUE indicates success. FALSE indicates failure.
例如:
void PlayMusic()
{
sndPlaySound("Theme.wav",SND_LOOP|SND_ASYNC);
}
然后在你的工程目录下放入一个Theme.wav的音乐文件,再运行程序的同时它就会开始播放的!
热心网友
时间:2023-10-09 12:41
这种问题确实比较难,请教专业老师吧追问这就是老师留的作业啊,要是老师管的话就不用提问啦!!!他说什么培养你们的自学能力云云~~~
热心网友
时间:2023-10-09 12:42
多线程 你们老师让你们写win窗口程序吗
要是的话 那这个特定功能是什么呢???追问不是win窗口的吧,就是什么学生信息统计系统,选修课管理系统,图书馆图书信息管理系统~之类的,有几个总体的要求,其中之一是在程序运行的同时要播放背景音乐~~~~~~具体的实现功能的主程序我会弄,而且已经快完事了。就是背景音乐不会弄啊...
多线程怎么弄啊?不懂啊~~~