1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| int main(int argc, char* argv[])
{
std::string file2 = std::string("1.wav");
int audio_rate = 44100 ;//??
Uint16 audio_format = AUDIO_S16SYS;
int audio_channels = 2;
int audio_buffers = 2048;
//std::string filemp3 = std::string("06 - OMAR - Your Mess.mp3");
//SDL Initialize
if (SDL_Init(SDL_INIT_AUDIO) != 0)
{
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0)
{
fprintf(stderr, "Unable to initialize audio: %s\n", Mix_GetError());
system("pause");
exit(1);
}
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
Mix_Music* m_mixMusic;
m_mixMusic = Mix_LoadMUS(file2.c_str());
Mix_PlayMusic(m_mixMusic, -1);
while (Mix_PlayingMusic()==1)
{
if(Mix_PlayMusic(m_mixMusic, -1)==-1)
{
printf("Mix_PlayMusic: %s\n", Mix_GetError());
}
SDL_Delay(500);
}
Mix_CloseAudio();
SDL_Quit();
return 0;
} |
Partager