Browse files

Make SDLx::Music match the docs: data returns hashref with no args, a…

…nd play can be called with $name
  • Loading branch information...
1 parent 095b0fb commit 6a3b4e6a5738de8627d64bc4082dc0dd254c23f2 @ioanrogers ioanrogers committed Jan 29, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/SDLx/Music.pm
View
9 lib/SDLx/Music.pm
@@ -45,7 +45,8 @@ sub new {
sub data {
my $self = shift;
- return if $#_ < 0;
+
+ return $self->{data} if $#_ == -1;
return $self->{data}->{ $_[0] } if $#_ == 0;
my %data = @_;
@@ -92,7 +93,11 @@ sub play {
my %override = @_;
return unless defined $play_data;
-
+
+ if ( ref $play_data eq '') {
+ $play_data = $self->{data}->{$play_data};
+ }
+
my $volume = $play_data->{volume} || $override{volume} || 50;
my $fade_in = $play_data->{fade_in} || $override{fade_in} || 0;
my $loops = $play_data->{loops} || $override{loops} || 1;

0 comments on commit 6a3b4e6

Please sign in to comment.