in reply to SDL::Mixer for Ubuntu 19.04

Can't locate object method "new" via package "SDL::Mixer" at test.pl line 8.

The documentation for SDL::Mixer does not list "new" as a method so the error report is likely correct. Perhaps the API has changed substantially since you last installed it? It does not appear to have an object orientated interface at all, AFAICS.

Replies are listed 'Best First'.
Re^2: SDL::Mixer for Ubuntu 19.04
by Dirk80 (Pilgrim) on Nov 03, 2019 at 18:14 UTC

    Thanks!! You are right. The API changed completely. I now changed the code as follows, and it works.:

    use SDL; use SDL::Mixer; use SDL::Mixer::Music; printf("Error initializing SDL_mixer: %s\n", SDL::get_error()) unless +SDL::Mixer::open_audio(22050, AUDIO_S16, 2, 1024) == 0; playMusicFile("test.wav"); sub playMusicFile { my $music_file = $_[0]; my $music = SDL::Mixer::Music::load_MUS( $music_file ); SDL::Mixer::Music::volume_music( 40 ); my $play_music = SDL::Mixer::Music::play_music( $music, 1 ); print $play_music; SDL::delay(10000); # fix delay, better would be a solution to wait + until song is finished, I have to find out this later }