NAME
Audio::MPD - class to talk to MPD (Music Player Daemon) servers
SYNOPSIS
use Audio::MPD;
my $mpd = Audio::MPD->new();
$mpd->play();
sleep 10;
$mpd->next();
DESCRIPTION
Audio::MPD gives a clear object-oriented interface for talking to and controlling MPD (Music Player Daemon) servers. A connection to the MPD server is established as soon as a new Audio::MPD object is created. Commands are then sent to the server as the class's methods are called.
METHODS
Constructor
- new( [$host] [, $port] [, $password] )
-
This is the constructor for Audio::MPD. One can specify a $hostname, a $port, and a $password.
If none is specified then defaults to environment vars MPD_HOST, MPD_PORT and MPD_PASSWORD. If those aren't set, defaults to 'localhost', 6600 and ''.
Controlling the server
- $mpd->ping()
-
Sends a ping command to the mpd server.
- $mpd->version()
-
Return the version number for the server we are connected to.
- $mpd->kill()
-
Send a message to the MPD server telling it to shut down.
- $mpd->password( [$password] )
-
Change password used to communicate with MPD server to $password. Empty string is assumed if $password is not supplied.
- $mpd->updatedb( [$path] )
-
Force mpd to recan its collection. If $path (relative to MPD's music directory) is supplied, MPD will only scan it - otherwise, MPD will rescan its whole collection.
- $mpd->urlhandlers()
-
Return an array of supported URL schemes.
Handling volume & output
- $mpd->volume( [+][-]$volume )
-
Sets the audio output volume percentage to absolute $volume. If $volume is prefixed by '+' or '-' then the volume is changed relatively by that value.
- $mpd->output_enable( $output )
-
Enable the specified audio output. $output is the ID of the audio output.
- $mpd->output_disable( $output )
-
Disable the specified audio output. $output is the ID of the audio output.
Retrieving info from current state
- $mpd->stats()
-
Return a hashref with the number of artists, albums, songs in the database, as well as mpd uptime, the playtime of the playlist / the database and the last update of the database
- $mpd->status()
-
Return an
Audio::MPD::Status
object with various information on current MPD server settings. Check the embedded pod for more information on the available accessors. - $mpd->current()
-
Return an
Audio::MPD::Item::Song
representing the song currently playing. - $mpd->song( [$song] )
-
Return an
Audio::MPD::Item::Song
representing the song number$song
. If$song
is not supplied, returns the current song. - $mpd->songid( [$songid] )
-
Return an
Audio::MPD::Item::Song
representing the song with id$songid
. If$songid
is not supplied, returns the current song.
Altering MPD settings
- $mpd->repeat( [$repeat] )
-
Set the repeat mode to $repeat (1 or 0). If $repeat is not specified then the repeat mode is toggled.
- $mpd->random( [$random] )
-
Set the random mode to $random (1 or 0). If $random is not specified then the random mode is toggled.
- $mpd->fade( [$seconds] )
-
Enable crossfading and set the duration of crossfade between songs. If $seconds is not specified or $seconds is 0, then crossfading is disabled.
Controlling playback
- $mpd->play( [$song] )
-
Begin playing playlist at song number $song. If no argument supplied, resume playing.
- $mpd->playid( [$songid] )
-
Begin playing playlist at song ID $songid. If no argument supplied, resume playing.
- $mpd->pause( [$state] )
-
Pause playback. If
$state
is 0 then the current track is unpaused, if $state is 1 then the current track is paused.Note that if
$state
is not given, pause state will be toggled. - $mpd->stop()
-
Stop playback.
- $mpd->next()
-
Play next song in playlist.
- $mpd->prev()
-
Play previous song in playlist.
- $mpd->seek( $time, [$song])
-
Seek to $time seconds in song number $song. If $song number is not specified then the perl module will try and seek to $time in the current song.
- $mpd->seekid( $time, $songid )
-
Seek to $time seconds in song ID $songid. If $song number is not specified then the perl module will try and seek to $time in the current song.
Searching the collection
To search the collection, use the collection()
accessor, returning the associated Audio::MPD::Collection
object. You will then be able to call:
$mpd->collection->random_song();
See Audio::MPD::Collection
documentation for more details on available methods.
Handling the playlist
To update the playlist, use the playlist()
accessor, returning the associated Audio::MPD::Playlist
object. You will then be able to call:
$mpd->playlist->clear;
See Audio::MPD::Playlist
documentation for more details on available methods.
SEE ALSO
You can find more information on the mpd project on its homepage at http://www.musicpd.org, or its wiki http://mpd.wikia.com.
Regarding this Perl module, you can report bugs on CPAN via http://rt.cpan.org/Public/Bug/Report.html?Queue=Audio-MPD.
Audio::MPD development takes place on <audio-mpd@googlegroups.com>: feel free to join us. (use http://groups.google.com/group/audio-mpd to sign in). Our subversion repository is located at https://svn.musicpd.org.
AUTHORS
Jerome Quelin <jquelin@cpan.org>
Original code by Tue Abrahamsen <tue.abrahamsen@gmail.com>, documented by Nicholas J. Humfrey <njh@aelius.com>.
COPYRIGHT AND LICENSE
Copyright (c) 2005 Tue Abrahamsen <tue.abrahamsen@gmail.com>
Copyright (c) 2006 Nicholas J. Humfrey <njh@aelius.com>
Copyright (c) 2007 Jerome Quelin <jquelin@cpan.org>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.