Commit | Line | Data |
71dfa2cb |
1 | #!/usr/bin/env perl |
2 | # |
3 | # This example plays a .WAV sound sample |
4 | # |
5 | use strict; |
6 | use warnings; |
7 | use SDL; |
8 | use SDL::Mixer; |
9 | use SDL::Sound; |
10 | |
11 | SDL::Init(SDL_INIT_AUDIO); |
12 | |
13 | my $filename = shift || 'data/sample.wav'; |
14 | |
15 | my $mixer = SDL::Mixer->new( |
16 | -frequency => 44100, |
17 | ); |
18 | print "Using audio driver: ", SDL::AudioDriverName(), "\n"; |
19 | |
20 | my $wave = SDL::Sound->new($filename); |
21 | |
22 | # we don't care what channel, and we only want to play it once |
23 | my $channel = $mixer->play_channel( -1, $wave, 0 ); |
24 | |
25 | # wait until it has finished playing |
26 | while ( $mixer->playing($channel) ) { |
27 | SDL::Delay(10); |
28 | } |
29 | |