nim-lang / sdl1

SDL v1.2 wrapper for Nim.
GNU Lesser General Public License v2.1
7 stars 4 forks source link

Can't get mp3 to play #3

Open ajusa opened 2 years ago

ajusa commented 2 years ago

I'm not 100% sure this is related to the binding, but I'm also not really sure why I can't get this to work.

When I use https://github.com/nim-lang/sdl2/blob/master/src/sdl2/mixer.nim, I am able to play an mp3 file. With the exact same code, but using the sdl_mixer in this repository, I get Unrecognized music format printed out. I believe this means I have all of the dynamic libraries properly installed and configured, otherwise I wouldn't be able to get SDL2 to work.

import sdl
import sdl_mixer
discard sdl.init(INIT_EVERYTHING)
discard openAudio(22050, AUDIO_S16SYS, 2, 640)
var music = loadMus("music.mp3")
echo getError()
discard music.playMusic(1)

EDIT: I tried reproducing a similar example in C, and noticed the Mix_Init function (which this wrapper omits, but the SDL2 wrapper has this function). After running that and checking for errors, I get Mix_Init: Mixer not built with MP3 support. Not sure if this is solvable on the end of this wrapper, but I'm also not sure if the Mix_Init function needs to be wrapped.

ajusa commented 2 years ago

Further update - I tried install SDL_mixer directly from the official website and I was able to get the C example working. The nim example however gives me

libSDL_mixer.so: cannot open shared object file: No such file or directory
could not load: libSDL_mixer.so

libSDL_mixer.so is inside my /usr/lib directory, so I'm not sure why it can't find it...