Audio-RPLD
view release on metacpan or search on metacpan
lib/Audio/RPLD.pm view on Meta::CPAN
=head2 Volume control
=cut
sub setvolume {
my ($e, $vol) = @_;
my $r;
# SETVOLUME {NUM|PC%}
if ( $vol =~ /^\d+\%$/ ) {
$r = $e->cmd('SETVOLUME', $vol);
} else {
$r = $e->cmd('SETVOLUME', int($vol));
}
return $e->is_ok($r);
}
=pod
=head3 $res = $rpld-E<gt>setvolume($vol)
Set volume to $vol.
=cut
sub showvolume {
my ($e) = @_;
my $q = $e->cmd_data('SHOWVOLUME');
my $r = {};
return undef unless $e->is_ok($q->[0]);
$q->[1] =~ /^VOLUME (\d+)\/(\d+) (\d+)%$/ or return undef;
%{$r} = ('value' => $1, 'scale' => $2, 'pc' => $3);
return $r;
}
=pod
=head3 $res = $rpld-E<gt>showvolume()
Return a hashref to a hash containing volume information.
The hash contains the following keys:
=over
=item value
The current playback volume in units of scale.
=item scale
The unit of value.
=item pc
The volume in percent.
=back
The current volume (as float) is value/scale.
=cut
=pod
=head2 Controlling pause state
=cut
sub pause {
my ($e) = @_;
return $e->is_ok($e->cmd('PAUSE', 'TRUE'));
}
=pod
=head3 $res = $rpld-E<gt>pause()
Set the playback in pause mode.
You should not use this function but $rpld->togglepause() if possible.
=cut
sub unpause {
my ($e) = @_;
return $e->is_ok($e->cmd('PAUSE', 'FALSE'));
}
=pod
=head3 $res = $rpld-E<gt>unpause()
Unpause the playback.
You should not use this function but $rpld->togglepause() if possible.
=cut
sub togglepause {
my ($e) = @_;
return $e->is_ok($e->cmd('PAUSE', 'TOGGLE'));
}
=pod
=head3 $res = $rpld-E<gt>togglepause()
Toggle the pause state. This is the recommended function to change the pause state of playback.
This is because it interacts best with other applications changing the current pause state.
=cut
( run in 0.705 second using v1.01-cache-2.11-cpan-39bf76dae61 )