- Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathSDLx_Sound.pl
62 lines (55 loc) · 1.25 KB
/
SDLx_Sound.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/perl
#==========================================================================
#
# FILE: SDLx_Sound.pl
#
# USAGE: ./examples/SDLx_Sound.pl
#
#
# DESCRIPTION: Sound tests
# A SDLx::Sound can play, pause, resume and stop
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Ricardo Filipo (rf), ricardo.filipo@gmail.com
# COMPANY: Mito-Lógica design e soluções de comunicação ltda
# VERSION: 1.0
# CREATED: 16-08-2010 21:47:33
# REVISION: ---
#==========================================================================
use strict;
use warnings;
use lib 'lib';
use SDL;
use SDLx::Sound;
use SDLx::App;
use SDL::Event;
use SDL::Events;
my$app = SDLx::App->new(
height=> 120,
width=> 480,
depth=> 16,
title=>'Sound example',
);
my$snd = SDLx::Sound->new();
# load and play a sound
my$play = $snd->play('test/data/sample.wav');
# pause or resume on keydown
$app->add_event_handler( sub{
my$e = $_[0];
$_[1]->stop() if$e->type == SDL_QUIT;
if( $e->type == SDL_KEYDOWN )
{
print"Ai\n";
if($play){
$snd->pause;
$play=0;
}else{
$snd->resume;
$play=1;
}
}
} );
$app->run();