veandco / go-sdl2

SDL2 binding for Go

Home Page:https://godoc.org/github.com/veandco/go-sdl2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Audio device hasn't been opened" - Not clear how to open the device.

billyninja opened this issue · comments

I'm a noob with SDL2, but I've tried several ways to init audio/open device and then play a .mp3, none worked. The sinewave example works fine.

Is this working? Can someone provide a minimum example?

I added some missing functions to the package. Could you try the audio_mp3 example I added? If it doesn't work, try the C version with gcc audio_mp3.c -lSDL2 -lSDL2_mixer if you're on Unix system.

In both, C and Go, I'm getting "Mixer not built with MP3 support" when it tries to init the mixer with INIT_MP3.

Thanks for the feedback!

Ah, in that case you need to install SDL2 from source. Not sure if this is a problem on Mac and Windows.

  1. Download the source code for SDL2 and SDL2_mixer at http://libsdl.org/download-2.0.php and https://www.libsdl.org/projects/SDL_mixer/ and unpack them.
  2. Go to SDL_mixer's folder and inside external/smpeg2-2.0.0/ folder, run ./autogen.sh then ./configure followed by make and finally sudo make install. This is to enable MP3 support when you're compiling SDL_mixer.
  3. Run the same command for SDL2 and SDL2_mixer folder. You might want to use make -j8 instead of make to make compilation faster (the -j number is usually double the number of your processor cores).
  4. Remove SDL2 and SDL2_mixer if you installed from package manager.

I am use win10.
Do you know where to get the run time lib of SDL2 & SDL_Mixer to support MP3 directly? Thanks.