On Mon, Nov 28, 2011 at 8:13 PM, Alexander Becker <alexanderbec...@gmx.net> wrote: > Dear all! >
Hi there! > I just tried the example code of the SDL Manual where you play some music. > By the SDL manual, I refer to the one that is hidden at the bottom of the > sdl.perl.org page, so that you really have to search for it in order to find > it - and even then you have to get along with an ugly github interface. > There's a new project website under way, but we're missing people to work in it. Please join #sdl in irc.perl.org if you want to help us get it right :) > So, in general: Is there a way to play mp3 files? Yup. If your libsdl was compiled with mp3 support, all you have to do (iirc) is set the MIX_INIT_MP3 (for effects) and MUS_MP3 (for audio) flags when you call SDL::Mixer::init(): SDL::Mixer::init( MIX_INIT_MP3 | MUS_MP3 ); then use load_MUS() and play_music() from SDL::Mixer::Music to play mp3 files as background music, or load_WAV() from SDL::Mixer::Samples to play mp3 effects (yes, the function is named load_WAV() but plays different formats too if they're available). The documentation in SDL::Mixer, SDL::Mixer::Music and SDL::Mixer::Samples should be helpful, as some of the test files (t/mixer_music.t comes to mind). > And in particular: is there a way to play mp3 files that are in a variable? > Or do I have to work with temporary files? > Not sure. I *think* SDL::Mixer::quick_load_WAV( $buffer ) might do the right thing. You'll have to test it though. Cheers, breno