|
Network.MPD | Portability | Haskell 98 | Stability | alpha | Maintainer | bsinclai@turing.une.edu.au |
|
|
|
|
|
Description |
MPD client library.
|
|
Synopsis |
|
|
|
|
Basic data types
|
|
data MPD a |
Instances | |
|
|
data MPDError |
The MPDError type is used to signal errors, both from the MPD and
otherwise.
| Constructors | NoMPD | MPD not responding
| TimedOut | The connection timed out
| Custom String | Used for misc. errors
| ACK ACKType String | ACK type and a message from the
server.
|
| Instances | |
|
|
data ACKType |
Represents various MPD errors (aka. ACKs).
| Constructors | InvalidArgument | Invalid argument passed (ACK 2)
| InvalidPassword | Invalid password supplied (ACK 3)
| Auth | Authentication required (ACK 4)
| UnknownCommand | Unknown command (ACK 5)
| FileNotFound | File or directory not found ACK 50)
| PlaylistMax | Playlist at maximum size (ACK 51)
| System | A system error (ACK 52)
| PlaylistLoad | Playlist loading failed (ACK 53)
| Busy | Update already running (ACK 54)
| NotPlaying | An operation requiring playback
got interrupted (ACK 55)
| FileExists | File already exists (ACK 56)
| UnknownACK | An unknown ACK (aka. bug)
|
|
|
|
type Response a = Either MPDError a |
A response is either an ACK or some result.
|
|
Command related data types
|
|
data State |
Represents the different playback states.
| Constructors | | Instances | |
|
|
data Status |
Container for MPD status.
| Constructors | Status | | stState :: State | | stVolume :: Int | A percentage (0-100)
| stRepeat :: Bool | | stRandom :: Bool | | stPlaylistVersion :: Integer | A value that is incremented by the server every time the
playlist changes.
| stPlaylistLength :: Integer | | stSongPos :: (Maybe PLIndex) | Current song's position in the playlist.
| stSongID :: (Maybe PLIndex) | Current song's playlist ID.
| stTime :: (Seconds, Seconds) | Time elapsed/total time.
| stBitrate :: Int | Bitrate (in kilobytes per second) of playing song (if any).
| stXFadeWidth :: Seconds | Crossfade time.
| stAudio :: (Int, Int, Int) | Samplerate/bits/channels for the chosen output device
(see mpd.conf).
| stUpdatingDb :: Integer | Job ID of currently running update (if any).
| stError :: String | Last error message (if any).
|
|
| Instances | |
|
|
data Stats |
Container for database statistics.
| Constructors | Stats | | stsArtists :: Integer | Number of artists.
| stsAlbums :: Integer | Number of albums.
| stsSongs :: Integer | Number of songs.
| stsUptime :: Seconds | Daemon uptime in seconds.
| stsPlaytime :: Seconds | Total playing time.
| stsDbPlaytime :: Seconds | Total play time of all the songs in
the database.
| stsDbUpdate :: Integer | Last database update in UNIX time.
|
|
| Instances | |
|
|
data Device |
Represents an output device.
| Constructors | Device | | dOutputID :: Int | Output's ID number
| dOutputName :: String | Output's name as defined in the MPD
configuration file
| dOutputEnabled :: Bool | |
|
| Instances | |
|
|
data Query |
A query is composed of a scope modifier and a query string.
| Constructors | Query Meta String | Simple query.
| MultiQuery [Query] | Query with multiple conditions.
|
| Instances | |
|
|
data Meta |
Available metadata types/scope modifiers, used for searching the
database for entries with certain metadata values.
| Constructors | Artist | | Album | | Title | | Track | | Name | | Genre | | Date | | Composer | | Performer | | Disc | | Any | | Filename | |
| Instances | |
|
|
type Artist = String |
|
type Album = String |
|
type Title = String |
|
type Seconds = Integer |
|
data PLIndex |
Represents a song's playlist index.
| Constructors | Pos Integer | A playlist position index (starting from 0)
| ID Integer | A playlist ID number that more robustly
identifies a song.
|
| Instances | |
|
|
data Song |
Represents a single song item.
| Constructors | Song | | sgArtist, sgAlbum, sgTitle, sgFilePath, sgGenre, sgName, sgComposer, sgPerformer :: String | | sgLength :: Seconds | Length in seconds
| sgDate :: Int | Year
| sgTrack :: (Int, Int) | Track number/total tracks
| sgDisc :: (Int, Int) | Position in set/total in set
| sgIndex :: (Maybe PLIndex) | |
|
| Instances | |
|
|
data Count |
Represents the result of running count.
| Constructors | Count | | cSongs :: Integer | Number of songs matching the query
| cPlaytime :: Seconds | Total play time of matching songs
|
|
| Instances | |
|
|
Admin commands
|
|
disableoutput :: Int -> MPD () |
Turn off an output device.
|
|
enableoutput :: Int -> MPD () |
Turn on an output device.
|
|
outputs :: MPD [Device] |
Retrieve information for all output devices.
|
|
update |
:: [String] | Optionally specify a list of paths
| -> MPD () | | Update the server's database.
|
|
|
Database commands
|
|
find :: Query -> MPD [Song] |
Search the database for entries exactly matching a query.
|
|
list |
|
|
listAll :: Maybe String -> MPD [String] |
List the songs (without metadata) in a database directory recursively.
|
|
listAllinfo |
|
|
lsinfo |
|
|
search :: Query -> MPD [Song] |
Search the database using case insensitive matching.
|
|
count :: Query -> MPD Count |
Count the number of entries matching a query.
|
|
Playlist commands
|
|
Unless otherwise noted all playlist commands operate on the current
playlist.
|
|
add :: Maybe String -> String -> MPD [String] |
Like add_ but returns a list of the files added.
|
|
add_ |
:: Maybe String | Optionally specify a playlist to operate on
| -> String | | -> MPD () | | Add a song (or a whole directory) to a playlist.
Adds to current if no playlist is specified.
Will create a new playlist if the one specified does not already exist.
|
|
|
addid :: String -> MPD Integer |
Like add, but returns a playlist id.
|
|
clear |
:: Maybe String | Optional name of a playlist to clear.
| -> MPD () | | Clear a playlist. Clears current playlist if no playlist is specified.
If the specified playlist does not exist, it will be created.
|
|
|
currentSong :: MPD (Maybe Song) |
Get the currently playing song.
|
|
delete |
:: Maybe String | Optionally specify a playlist to operate on
| -> PLIndex | | -> MPD () | | Remove a song from a playlist.
If no playlist is specified, current playlist is used.
Note that a playlist position (Pos) is required when operating on
playlists other than the current.
|
|
|
load :: String -> MPD () |
Load an existing playlist.
|
|
move |
:: Maybe String | Optionally specify a playlist to operate on
| -> PLIndex | | -> Integer | | -> MPD () | | Move a song to a given position.
Note that a playlist position (Pos) is required when operating on
playlists other than the current.
|
|
|
playlistinfo |
:: Maybe PLIndex | Optional playlist index.
| -> MPD [Song] | | Retrieve metadata for songs in the current playlist.
|
|
|
listplaylist :: String -> MPD [String] |
Retrieve a list of files in a given playlist.
|
|
listplaylistinfo :: String -> MPD [Song] |
Retrieve metadata for files in a given playlist.
|
|
playlist :: MPD [(PLIndex, String)] |
Retrieve file paths and positions of songs in the current playlist.
Note that this command is only included for completeness sake; it's
deprecated and likely to disappear at any time.
|
|
plchanges :: Integer -> MPD [Song] |
Retrieve a list of changed songs currently in the playlist since
a given playlist version.
|
|
plchangesposid :: Integer -> MPD [(PLIndex, PLIndex)] |
Like plchanges but only returns positions and ids.
|
|
playlistfind :: Query -> MPD [Song] |
Search for songs in the current playlist with strict matching.
|
|
playlistsearch :: Query -> MPD [Song] |
Search case-insensitively with partial matches for songs in the
current playlist.
|
|
rm :: String -> MPD () |
Delete existing playlist.
|
|
rename |
:: String | Name of playlist to be renamed
| -> String | New playlist name
| -> MPD () | | Rename an existing playlist.
|
|
|
save :: String -> MPD () |
Save the current playlist.
|
|
shuffle :: MPD () |
Shuffle the playlist.
|
|
swap :: PLIndex -> PLIndex -> MPD () |
Swap the positions of two songs.
Note that the positions must be of the same type, i.e. mixing Pos and ID
will result in a no-op.
|
|
Playback commands
|
|
crossfade :: Seconds -> MPD () |
Set crossfading between songs.
|
|
next :: MPD () |
Play the next song.
|
|
pause :: Bool -> MPD () |
Pause playing.
|
|
play :: Maybe PLIndex -> MPD () |
Begin/continue playing.
|
|
previous :: MPD () |
Play the previous song.
|
|
random :: Bool -> MPD () |
Set random playing.
|
|
repeat :: Bool -> MPD () |
Set repeating.
|
|
seek :: Maybe PLIndex -> Seconds -> MPD () |
Seek to some point in a song.
Seeks in current song if no position is given.
|
|
setVolume :: Int -> MPD () |
Set the volume.
|
|
volume :: Int -> MPD () |
Increase or decrease volume by a given percent, e.g.
'volume 10' will increase the volume by 10 percent, while
'volume (-10)' will decrease it by the same amount.
Note that this command is only included for completeness sake ; it's
deprecated and may disappear at any time.
|
|
stop :: MPD () |
Stop playing.
|
|
Miscellaneous commands
|
|
clearerror :: MPD () |
Clear the current error message in status.
|
|
close :: MPD () |
Close an MPD connection.
|
|
commands :: MPD [String] |
Retrieve a list of available commands.
|
|
notcommands :: MPD [String] |
Retrieve a list of unavailable commands.
|
|
tagtypes :: MPD [String] |
Retrieve a list of available song metadata.
|
|
urlhandlers :: MPD [String] |
Retrieve a list of supported urlhandlers.
|
|
password :: String -> MPD () |
Send password to server to authenticate session.
Password is sent as plain text.
|
|
ping :: MPD () |
Check that the server is still responding.
|
|
reconnect :: MPD () |
Refresh a connection.
|
|
stats :: MPD Stats |
Get server statistics.
|
|
status :: MPD Status |
Get the server's status.
|
|
Extensions/shortcuts
|
|
addMany :: Maybe String -> [String] -> MPD () |
Add a list of songs/folders to a playlist.
Should be more efficient than running add many times.
|
|
deleteMany :: Maybe String -> [PLIndex] -> MPD () |
Delete a list of songs from a playlist.
If there is a duplicate then no further songs will be deleted, so
take care to avoid them (see prune for this).
|
|
crop :: Maybe PLIndex -> Maybe PLIndex -> MPD () |
Crop playlist.
The bounds are inclusive.
If Nothing or ID is passed the cropping will leave your playlist alone
on that side.
|
|
prune :: MPD () |
Remove duplicate playlist entries.
|
|
lsdirs |
|
|
lsfiles |
|
|
lsplaylists :: MPD [String] |
List all playlists.
|
|
findArtist :: Artist -> MPD [Song] |
Search the database for songs relating to an artist.
|
|
findAlbum :: Album -> MPD [Song] |
Search the database for songs relating to an album.
|
|
findTitle :: Title -> MPD [Song] |
Search the database for songs relating to a song title.
|
|
listArtists :: MPD [Artist] |
List the artists in the database.
|
|
listAlbums :: Maybe Artist -> MPD [Album] |
List the albums in the database, optionally matching a given
artist.
|
|
listAlbum :: Artist -> Album -> MPD [Song] |
List the songs in an album of some artist.
|
|
searchArtist :: Artist -> MPD [Song] |
Search the database for songs relating to an artist using search.
|
|
searchAlbum :: Album -> MPD [Song] |
Search the database for songs relating to an album using search.
|
|
searchTitle :: Title -> MPD [Song] |
Search the database for songs relating to a song title.
|
|
getPlaylist :: MPD [Song] |
Retrieve the current playlist.
Equivalent to 'playlistinfo Nothing'.
|
|
toggle :: MPD () |
Toggles play/pause. Plays if stopped.
|
|
updateid :: [String] -> MPD Integer |
Like update, but returns the update job id.
|
|
Connections
|
|
withMPD :: MPD a -> IO (Response a) |
Run an MPD action using localhost:6600 as the default host:port,
or whatever is found in the environment variables MPD_HOST and
MPD_PORT. If MPD_HOST is of the form "password@host" then the
password will be supplied as well.
|
|
withMPDEx |
|
|
Misc.
|
|
kill :: MPD () |
Kill the server. Obviously, the connection is then invalid.
|
|
throwMPD :: MPDError -> MPD () |
Throw an exception.
|
|
catchMPD :: MPD a -> (MPDError -> MPD a) -> MPD a |
Catch an exception from an action.
|
|
Produced by Haddock version 0.8 |