#include <SDL.h>
#include <SDL_mixer.h>
int main(int argc,char ** argv)
{
// 初始化.
SDL_Init(SDL_INIT_AUDIO);//设备初始化
Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 4096 ) ;//关键三句来了,格式初始化
Mix_Music *music = Mix_LoadMUS(argv[1]);//任意mp3拖到文件上执行,注意歌曲要英文名的
Mix_PlayMusic(music,1);//播放
while (Mix_PlayingMusic());//你也可以用延时替换这句
Mix_FreeMusic(music);//以下释放资源
Mix_CloseAudio();
SDL_Quit();
return 0;
}
//编译命令gcc "test.c" -IC:\MinGW\include\SDL2 -lmingw32 -lSDL2main -lSDL2 -lSDL2_mixer -o "test"