NAME
Net::MPD - Communicate with an MPD server
SYNOPSIS
use Net::MPD;
my $mpd = Net::MPD->connect();
$mpd->stop();
$mpd->clear();
$mpd->search_add(Artist => 'David Bowie');
$mpd->shuffle();
$mpd->play();
$mpd->next();
while (1) {
my @changes = $mpd->idle();
print 'Changed: ' . join(', ', @changes) . "\n";
}
DESCRIPTION
Net::MPD is designed as a lightweight replacment for Audio::MPD which depends on Moose and is no longer maintained.
METHODS
connect
Connects to the MPD running at the given address. Address takes the form of password@host:port. Both the password and port are optional. If no password is given, none will be used. If no port is given, the default (6600) will be used. If no host is given, localhost
will be used.
Returns a Net::MPD object on success and croaks on failure.
version
Returns the API version of the connected MPD server.
update_status
Issues a status
command to MPD and stores the results in the local object. The results are also returned as a hashref.
MPD ATTRIBUTES
Most of the "status" attributes have been written as combined getter/setter methods. Calling the "update_status" method will update these values. Only the items marked with an asterisk are writable.
- volume*
- repeat*
- random*
- single*
- consume*
- playlist
- playlist_length
- state
- song
- song_id
- next_song
- next_song_id
- time
- elapsed
- bitrate
- crossfade*
- mix_ramp_db*
- mix_ramp_delay*
- audio
- updating_db
- error
- replay_gain_mode*
MPD COMMANDS
The commands are mostly the same as the MPD protocol but some have been renamed slightly.
- clear_error
- current_song
- idle
- stats
- next
- pause
- play
- play_id
- previous
- seek
- seek_id
- seek_cur
- stop
- add
- add_id
- clear
- delete
- delete_id
- move
- move_id
- playlist_find
- playlist_id
- playlist_info
- playlist_search
- playlist_changes
- playlist_changes_pos_id
- prio
- prio_id
- shuffle
- swap
- swapid
- list_playlist
- list_playlist_info
- list_playlists
- load
- playlist_add
- playlist_clear
- playlist_delete
- playlist_move
- rename
- rm
- save
- count
- find
- find_add
- list
- list_all
- list_all_info
- ls_info
- search
- search_add
- search_add_pl
- update
- rescan
- sticker
- close
- kill
- ping
- disable_output
- enable_output
- outputs
- config
- commands
- not_commands
- tag_types
- url_handlers
- decoders
- subscribe
- unsubscribe
- channels
- read_messages
- send_message
TODO
Command Lists
MPD supports sending batches of commands but that is not yet available with this API.
Asynchronous IO
Event-based handling of the idle command would make this module more robust.
BUGS
Idle connections
MPD will close the connection if left idle for too long. This module will reconnect if it senses that this has occurred, but the first call after a disconnect will fail and have to be retried. Calling the ping
command periodically will keep the connection open if you do not have any real commands to issue. Calling the idle
command will block until something interesting happens.
Reporting
Report any issues on GitHub
AUTHOR
Alan Berndt <alan@eatabrick.org>
COPYRIGHT
Copyright 2013 Alan Berndt
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.