Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

playing mp3 files with SDL on Win32

by Dirk80 (Monk)
on Nov 29, 2009 at 15:58 UTC ( #810016=perlquestion: print w/ replies, xml ) Need Help??
Dirk80 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

The following code is working perfectly when I'm using my linux OS.

#!/usr/bin/perl use strict; use warnings; use SDL::Mixer; use SDL::Music; my $mixer = eval { SDL::Mixer->new(-frequency => 44100, -channels => 2 +, -size => 1024); }; $mixer->music_volume(20); my $music = new SDL::Music './test.mp3' or die $!; $mixer->play_music($music,0); #0 for single play while(1) { if( $mixer->playing_music() ) { sleep(1); } else { last; } }

But when I'm using Windows Vista it is not working. I get the follwing error message:

Module format not recognized at play_mp3.pl line 13

What do I have to do to play a mp3 file with sdl on Windows Vista?

Thank you very much for your help

Dirk

Comment on playing mp3 files with SDL on Win32
Select or Download Code
Re: playing mp3 files with SDL on Win32
by keszler (Priest) on Nov 29, 2009 at 16:44 UTC
    According to http://matrix.cpantesters.org/?dist=SDL_Perl%20v2.2.6;maxver=1 no version of SDL_Perl has ever passed testing on Windows. The latest version passed only on Linux and Solaris.

    Update: The Build.PL for SDL_Perl contains the following:

    print STDERR <<BROKENWIN if ($^O =~ /MSWin.*|cygwin/ ); *************************** !!!WARNING!!! **************************** +* Windows support is currently experimental - you can continue, but you've been warned! If you are interested in helping please contact us + at sdl-devel\@perl.org, or join us on #sdl in irc.perl.org ********************************************************************** +* BROKENWIN
Re: playing mp3 files with SDL on Win32
by spx2 (Chaplain) on Nov 29, 2009 at 16:59 UTC
    see the current work of kthakore, there are fresh efforts of re-writing the SDL bindings for Perl. maybee this is a bug? either way go talk to them on irc.perl.org #sdl
      For me it works with SDL_perl v2.2.6 (latest official release from cpan) You can get it here: http://search.cpan.org/~kthakore/SDL_Perl-v2.2.6/ My testfile is 128kbit/s CBR 44kHz stereo. What is yours? (maybe VBR related issues) I you have further problems/questions you can join us on irc.perl.org channel #sdl or on sdl.perl.org (note that the documentation on our site is for the newer developement version of SDl_Perl) FROGGS
Re: playing mp3 files with SDL on Win32
by Joost (Canon) on Nov 29, 2009 at 23:47 UTC
Re: playing mp3 files with SDL on Win32
by Anonymous Monk on Nov 30, 2009 at 04:41 UTC
    You need to build libsdl with mp3 support
      i have just installed Win32::MediaPlayer (the easy way) from
      http://www.bribes.org/perl/ppmdir.html
      it can play sound MP3 / WMA / WAV / MIDI file on Win32 platforms
      i have tried successfully an example from the docs:
      use Win32::MediaPlayer; $winmm = new Win32::MediaPlayer; # new an object $winmm->load('./misty.mp3'); # Load music file disk, or an URL $winmm->play; # Play the music $winmm->volume(100); # Set volume after playing $winmm->seek('00:00'); # seek to #$winmm->pause; # Pause music playing #$winmm->resume; # Resume music playing print 'Total Length : '.$winmm->length(1),$/; # Show total time. while(1) { sleep 1; print 'Now Position: '.$winmm->pos(1)."\r"; # Show now time };
Re: playing mp3 files with SDL on Win32
by kthakore (Acolyte) on Dec 01, 2009 at 01:01 UTC
    Hi Dirk, We have looked into this problem and added a ticket for it on our bug tracker. Ticket 74 . So far your code seems to work on winXP. We don't have a developer with Vista however. Dirk80, to get a better error report please change your code to the following. In the next release we will be updating Mixer bindings so this may be fixed soon. Please give us feed back on sdl-devel@perl.org or #sdl irc.perl.org.
    use strict; use warnings; use SDL v2.2.6; # This is for the old API use SDL::Mixer; use SDL::Music; SDL::Init(SDL_INIT_AUDIO); my $mixer = eval { SDL::Mixer->new(-frequency => 44100, -channels => 2 +, -size => 1024); }; $mixer->music_volume(20); my $music = new SDL::Music './test.mp3' or die "$! and SDL Error is".S +DL::GetError(); $mixer->play_music($music,0); #0 for single play while(1) { if( $mixer->playing_music() ) { sleep(1); } else { last; } }

      Hi Dirk80, please have a look at http:://sdl.perl.org

      SDL::Mixer::Music is implemented now correctly and the API has changed and is documented.

      We'll close this BUG in our tracking system. You can reopen it if you have further problems. Or contact us on irc.

      cheers, Tobias Leich/FROGGS

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://810016]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2014-04-20 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls