¿Cómo reproducir música de fondo en un programa C++?
El código del caso es el siguiente
# include & ltwindows.h & gt
# include & ltstdio.h & gt
#pragma comment(lib, "WinMM.Lib")
void main()
{
PlaySound("c: \\dui12. wav ", NULL, SND_FILENAME | SND_ASYNC);
}
2. La función es tan mala como Playsound y undplaysound.
# incluir & ltwindows.h & gt
# incluir & ltstdio.h & gt
#pragma comment(lib, "WinMM.Lib")
void main()
{
undPlaySound(" c:\ \ du i12 . wav ", NULL, SND _ FILENAME | SND _ ASYNC); /p>
}
3. Potente, la clase MCI admite mezclas.
El código del caso es el siguiente
# include & ltwindows.h & gt
#include "mmsystem.h"//Importa el archivo de encabezado de sonido.
# pragma comment (lib, " winmm . lib ") // Importa la biblioteca de archivos de encabezado de sonido.
# include & ltstdio.h & gt
void play MP3();
void main()
{
reproducir MP3();
PlaySound("C:\\Normal2.wav ", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
sistema("pausa") ;
}
void PlayMp3()
{
char buf[128];
char str [128]= { 0 };
int I = 0
//Usar mciSendCommand
MCI _ OPEN _ PARMS mciOpen
MCIERROR mciError
//SetWindowText(NULL, " 12345 ");
MCI open .lpstrdevicetype = " vídeo mpeg "
MCI open .lpstrelementname = "c:\\BIENVENIDO.
WAV ";
mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&MCI abierto);
if(mciError)
{
mciGetErrorString(mciError, buf, 128);
printf("Error al enviar el comando MCI_OPEN: %s\n ", buf);
Retorno;
}
ID del dispositivo UINT = MCI abierto wdeviceid;
MCI _ PLAY _ PARMS mciPlay
Error de MCI = mciSendCommand(dispositivo id, MCI_PLAY, 0, (DWORD)&MCI play);
if(mciError)
{
printf("Error al enviar el comando MCI_PLAY\ n ");
Regresar;
}
}
4. La forma de resolver la función basura es iniciar una reproducción software en la computadora
# include & ltiostream & gt
# include & ltfstream & gt
Usar espacio de nombres estándar
int main()
{
System("D:\\Mi música\ \ 01 . MP3 "); CIN . /p>
Devuelve 0;
}
5: DX más potente
No quiero introducir demasiado, así que no lo haré. No lo codifiques. ¡Qué cansado! Hay explicaciones en línea