Audio-Daemon

 view release on metacpan or  search on metacpan

Daemon/Client.pm  view on Meta::CPAN

=head1 DESCRIPTION

This is one possible Client for Audio::Daemon.

This client portion communicates to the Server via UDP 
message passing and has no dependancies other then 
IO::Socket and IO::Select.

Most of this is best demostrated by examples, so I'll try to
keep the examples up to date.

=head1 CONSTRUCTORS

There is but one method to contruct a new C<Audio::Daemon::Client> object:

=over 4

=item Audio::Daemon::Client->new(Server => $server, Port => $port, [Log => \&logsub]);

The new method can take the following arguments:

=over 4

=item Server

This specifies the IP address of the C<Audio::Daemon::Server> server, it is required.

=item Port

The port the server is listening on (we snag whatever local port IO::Socket chooses).

=item Log

This takes a reference to a function that's called for logging purposes, the format passed in is:

=over 4

<type>, <msg>, [caller(1)]

where <type> is one of debug, info, error, crit, warn.  <msg> is the text message, and [caller] is 
the array returned by the second form of the perlfunc caller().  This will give you the method,
line number, etc. of where the messagee is coming from.  With this logging feature, I don't have to worry
about syslog, stdout, or how to report errors or debug info... you do!

=back 4

=over 4

=over 4

=head1 METHODS

I tried to stay as close the Audio::Play::MPG123 methods as possible with a few exceptions noted below.

=over 4

=item add [list of urls]

Needs to have arguments (array or array ref) of urls to load on the server.  If you're calling an mp3 
file it obviously needs access by the server, not the client.  It can be simple filenames, or urls
including http: urls for streaming to the server.  If there are tracks already in the playlist on the server
these will be tacked on to the end of the list.  If random mode is on, it will re-randomize the entire list
when it is finished adding (see the random feature).

=item del [list of index numbers]

Takes either the index number of tracks to remove or the keyword "all" to clear out the tracks.  If the
player is currently playing a track you removed it will internally call "next" to move the next track.  If 
you remove all tracks, it will cease to play until you add tracks back in.

=item stop

Stops the player if it's playing, otherwise it won't stop a non-playing player.

=item play

Starts the player if it's not playing, otherwise it lets a playing player play.

=item pause

Pauses the player if it's not paused, unpauses if it is paused.

=item next

Moves to the next track, this should not cause it to start playing if it is isn't currently.

=item prev

Goes in the opposite direction of next, but again, won't start it playing if it's not.

=item list

This causes the current playlist to be sent back with the next status update that normally 
occurs after each instruction (including the list command).  The Play List is then accessed
via the B<status> method.

=item jump ([+-]#[s])

Jump is very similiar to the Audio::Play::MPG123 command.  It accepts one argument that can get
a wee bit complicated but follow me on this, it has three parts, only one part is required:

<plus or minus><a digit><seconds>

This is best described with examples:

10s   (moves 10 seconds from the beginning of the track)
165s  (moves to 2:35 in the current track)
+10s  (moves forward 10 seconds from current track position)
-10s  (moves back 10 seconds from current track position)
10    (moves to the tenth frame -- see the "frame" status)

Most people would avoid the last example, but it's there for compatability issues.

=item vol ([vol|left], [right)

If you have the Audio::Mixer volume on the server, it will set the volume.  If one argument is passed in
it will equally set the right and left channels, if two arguments are passed in it will set left and right 
volumes respectively.

=item random (1|0)



( run in 1.071 second using v1.01-cache-2.11-cpan-39bf76dae61 )