libmpd-0.1.3: An MPD client library.Source codeContentsIndex
Network.MPD
PortabilityHaskell 98
Stabilityalpha
Maintainerbsinclai@turing.une.edu.au
Contents
Basic data types
Command related data types
Admin commands
Database commands
Playlist commands
Playback commands
Miscellaneous commands
Extensions/shortcuts
Connections
Misc.
Description
MPD client library.
Synopsis
data MPD a
data MPDError
= NoMPD
| TimedOut
| Custom String
| ACK ACKType String
data ACKType
= InvalidArgument
| InvalidPassword
| Auth
| UnknownCommand
| FileNotFound
| PlaylistMax
| System
| PlaylistLoad
| Busy
| NotPlaying
| FileExists
| UnknownACK
type Response a = Either MPDError a
data State
= Playing
| Stopped
| Paused
data Status = Status {
stState :: State
stVolume :: Int
stRepeat :: Bool
stRandom :: Bool
stPlaylistVersion :: Integer
stPlaylistLength :: Integer
stSongPos :: Maybe PLIndex
stSongID :: Maybe PLIndex
stTime :: (Seconds, Seconds)
stBitrate :: Int
stXFadeWidth :: Seconds
stAudio :: (Int, Int, Int)
stUpdatingDb :: Integer
stError :: String
}
data Stats = Stats {
stsArtists :: Integer
stsAlbums :: Integer
stsSongs :: Integer
stsUptime :: Seconds
stsPlaytime :: Seconds
stsDbPlaytime :: Seconds
stsDbUpdate :: Integer
}
data Device = Device {
dOutputID :: Int
dOutputName :: String
dOutputEnabled :: Bool
}
data Query
= Query Meta String
| MultiQuery [Query]
data Meta
= Artist
| Album
| Title
| Track
| Name
| Genre
| Date
| Composer
| Performer
| Disc
| Any
| Filename
type Artist = String
type Album = String
type Title = String
type Seconds = Integer
data PLIndex
= Pos Integer
| ID Integer
data Song = Song {
sgArtist :: String
sgAlbum :: String
sgTitle :: String
sgFilePath :: String
sgGenre :: String
sgName :: String
sgComposer :: String
sgPerformer :: String
sgLength :: Seconds
sgDate :: Int
sgTrack :: (Int, Int)
sgDisc :: (Int, Int)
sgIndex :: Maybe PLIndex
}
data Count = Count {
cSongs :: Integer
cPlaytime :: Seconds
}
disableoutput :: Int -> MPD ()
enableoutput :: Int -> MPD ()
outputs :: MPD [Device]
update :: [String] -> MPD ()
find :: Query -> MPD [Song]
list :: Meta -> Maybe Query -> MPD [String]
listAll :: Maybe String -> MPD [String]
listAllinfo :: Maybe String -> MPD [Either String Song]
lsinfo :: Maybe String -> MPD [Either String Song]
search :: Query -> MPD [Song]
count :: Query -> MPD Count
add :: Maybe String -> String -> MPD [String]
add_ :: Maybe String -> String -> MPD ()
addid :: String -> MPD Integer
clear :: Maybe String -> MPD ()
currentSong :: MPD (Maybe Song)
delete :: Maybe String -> PLIndex -> MPD ()
load :: String -> MPD ()
move :: Maybe String -> PLIndex -> Integer -> MPD ()
playlistinfo :: Maybe PLIndex -> MPD [Song]
listplaylist :: String -> MPD [String]
listplaylistinfo :: String -> MPD [Song]
playlist :: MPD [(PLIndex, String)]
plchanges :: Integer -> MPD [Song]
plchangesposid :: Integer -> MPD [(PLIndex, PLIndex)]
playlistfind :: Query -> MPD [Song]
playlistsearch :: Query -> MPD [Song]
rm :: String -> MPD ()
rename :: String -> String -> MPD ()
save :: String -> MPD ()
shuffle :: MPD ()
swap :: PLIndex -> PLIndex -> MPD ()
crossfade :: Seconds -> MPD ()
next :: MPD ()
pause :: Bool -> MPD ()
play :: Maybe PLIndex -> MPD ()
previous :: MPD ()
random :: Bool -> MPD ()
repeat :: Bool -> MPD ()
seek :: Maybe PLIndex -> Seconds -> MPD ()
setVolume :: Int -> MPD ()
volume :: Int -> MPD ()
stop :: MPD ()
clearerror :: MPD ()
close :: MPD ()
commands :: MPD [String]
notcommands :: MPD [String]
tagtypes :: MPD [String]
urlhandlers :: MPD [String]
password :: String -> MPD ()
ping :: MPD ()
reconnect :: MPD ()
stats :: MPD Stats
status :: MPD Status
addMany :: Maybe String -> [String] -> MPD ()
deleteMany :: Maybe String -> [PLIndex] -> MPD ()
crop :: Maybe PLIndex -> Maybe PLIndex -> MPD ()
prune :: MPD ()
lsdirs :: Maybe String -> MPD [String]
lsfiles :: Maybe String -> MPD [String]
lsplaylists :: MPD [String]
findArtist :: Artist -> MPD [Song]
findAlbum :: Album -> MPD [Song]
findTitle :: Title -> MPD [Song]
listArtists :: MPD [Artist]
listAlbums :: Maybe Artist -> MPD [Album]
listAlbum :: Artist -> Album -> MPD [Song]
searchArtist :: Artist -> MPD [Song]
searchAlbum :: Album -> MPD [Song]
searchTitle :: Title -> MPD [Song]
getPlaylist :: MPD [Song]
toggle :: MPD ()
updateid :: [String] -> MPD Integer
withMPD :: MPD a -> IO (Response a)
withMPDEx :: String -> Integer -> IO (Maybe String) -> MPD a -> IO (Response a)
kill :: MPD ()
throwMPD :: MPDError -> MPD ()
catchMPD :: MPD a -> (MPDError -> MPD a) -> MPD a
Basic data types
data MPD a Source
show/hide Instances
data MPDError Source
The MPDError type is used to signal errors, both from the MPD and otherwise.
Constructors
NoMPDMPD not responding
TimedOutThe connection timed out
Custom StringUsed for misc. errors
ACK ACKType StringACK type and a message from the server.
show/hide Instances
data ACKType Source
Represents various MPD errors (aka. ACKs).
Constructors
InvalidArgumentInvalid argument passed (ACK 2)
InvalidPasswordInvalid password supplied (ACK 3)
AuthAuthentication required (ACK 4)
UnknownCommandUnknown command (ACK 5)
FileNotFoundFile or directory not found ACK 50)
PlaylistMaxPlaylist at maximum size (ACK 51)
SystemA system error (ACK 52)
PlaylistLoadPlaylist loading failed (ACK 53)
BusyUpdate already running (ACK 54)
NotPlayingAn operation requiring playback got interrupted (ACK 55)
FileExistsFile already exists (ACK 56)
UnknownACKAn unknown ACK (aka. bug)
type Response a = Either MPDError aSource
A response is either an ACK or some result.
Command related data types
data State Source
Represents the different playback states.
Constructors
Playing
Stopped
Paused
show/hide Instances
data Status Source
Container for MPD status.
Constructors
Status
stState :: State
stVolume :: IntA percentage (0-100)
stRepeat :: Bool
stRandom :: Bool
stPlaylistVersion :: IntegerA value that is incremented by the server every time the playlist changes.
stPlaylistLength :: Integer
stSongPos :: Maybe PLIndexCurrent song's position in the playlist.
stSongID :: Maybe PLIndexCurrent song's playlist ID.
stTime :: (Seconds, Seconds)Time elapsed/total time.
stBitrate :: IntBitrate (in kilobytes per second) of playing song (if any).
stXFadeWidth :: SecondsCrossfade time.
stAudio :: (Int, Int, Int)Samplerate/bits/channels for the chosen output device (see mpd.conf).
stUpdatingDb :: IntegerJob ID of currently running update (if any).
stError :: StringLast error message (if any).
show/hide Instances
data Stats Source
Container for database statistics.
Constructors
Stats
stsArtists :: IntegerNumber of artists.
stsAlbums :: IntegerNumber of albums.
stsSongs :: IntegerNumber of songs.
stsUptime :: SecondsDaemon uptime in seconds.
stsPlaytime :: SecondsTotal playing time.
stsDbPlaytime :: SecondsTotal play time of all the songs in the database.
stsDbUpdate :: IntegerLast database update in UNIX time.
show/hide Instances
data Device Source
Represents an output device.
Constructors
Device
dOutputID :: IntOutput's ID number
dOutputName :: StringOutput's name as defined in the MPD configuration file
dOutputEnabled :: Bool
show/hide Instances
data Query Source
A query is composed of a scope modifier and a query string.
Constructors
Query Meta StringSimple query.
MultiQuery [Query]Query with multiple conditions.
show/hide Instances
data Meta Source
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
show/hide Instances
type Artist = StringSource
type Album = StringSource
type Title = StringSource
type Seconds = IntegerSource
data PLIndex Source
Represents a song's playlist index.
Constructors
Pos IntegerA playlist position index (starting from 0)
ID IntegerA playlist ID number that more robustly identifies a song.
show/hide Instances
data Song Source
Represents a single song item.
Constructors
Song
sgArtist :: String
sgAlbum :: String
sgTitle :: String
sgFilePath :: String
sgGenre :: String
sgName :: String
sgComposer :: String
sgPerformer :: String
sgLength :: SecondsLength in seconds
sgDate :: IntYear
sgTrack :: (Int, Int)Track number/total tracks
sgDisc :: (Int, Int)Position in set/total in set
sgIndex :: Maybe PLIndex
show/hide Instances
data Count Source
Represents the result of running count.
Constructors
Count
cSongs :: IntegerNumber of songs matching the query
cPlaytime :: SecondsTotal play time of matching songs
show/hide Instances
Admin commands
disableoutput :: Int -> MPD ()Source
Turn off an output device.
enableoutput :: Int -> MPD ()Source
Turn on an output device.
outputs :: MPD [Device]Source
Retrieve information for all output devices.
updateSource
:: [String]Optionally specify a list of paths
-> MPD ()
Update the server's database.
Database commands
find :: Query -> MPD [Song]Source
Search the database for entries exactly matching a query.
listSource
:: MetaMetadata to list
-> Maybe Query
-> MPD [String]
List all metadata of metadata (sic).
listAll :: Maybe String -> MPD [String]Source
List the songs (without metadata) in a database directory recursively.
listAllinfoSource
:: Maybe StringOptionally specify a path
-> MPD [Either String Song]
Recursive lsinfo.
lsinfoSource
:: Maybe StringOptionally specify a path.
-> MPD [Either String Song]
Non-recursively list the contents of a database directory.
search :: Query -> MPD [Song]Source
Search the database using case insensitive matching.
count :: Query -> MPD CountSource
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]Source
Like add_ but returns a list of the files added.
add_Source
:: Maybe StringOptionally 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 IntegerSource
Like add, but returns a playlist id.
clearSource
:: Maybe StringOptional 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)Source
Get the currently playing song.
deleteSource
:: Maybe StringOptionally 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 ()Source
Load an existing playlist.
moveSource
:: Maybe StringOptionally 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.
playlistinfoSource
:: Maybe PLIndexOptional playlist index.
-> MPD [Song]
Retrieve metadata for songs in the current playlist.
listplaylist :: String -> MPD [String]Source
Retrieve a list of files in a given playlist.
listplaylistinfo :: String -> MPD [Song]Source
Retrieve metadata for files in a given playlist.
playlist :: MPD [(PLIndex, String)]Source
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]Source
Retrieve a list of changed songs currently in the playlist since a given playlist version.
plchangesposid :: Integer -> MPD [(PLIndex, PLIndex)]Source
Like plchanges but only returns positions and ids.
playlistfind :: Query -> MPD [Song]Source
Search for songs in the current playlist with strict matching.
playlistsearch :: Query -> MPD [Song]Source
Search case-insensitively with partial matches for songs in the current playlist.
rm :: String -> MPD ()Source
Delete existing playlist.
renameSource
:: StringName of playlist to be renamed
-> StringNew playlist name
-> MPD ()
Rename an existing playlist.
save :: String -> MPD ()Source
Save the current playlist.
shuffle :: MPD ()Source
Shuffle the playlist.
swap :: PLIndex -> PLIndex -> MPD ()Source
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 ()Source
Set crossfading between songs.
next :: MPD ()Source
Play the next song.
pause :: Bool -> MPD ()Source
Pause playing.
play :: Maybe PLIndex -> MPD ()Source
Begin/continue playing.
previous :: MPD ()Source
Play the previous song.
random :: Bool -> MPD ()Source
Set random playing.
repeat :: Bool -> MPD ()Source
Set repeating.
seek :: Maybe PLIndex -> Seconds -> MPD ()Source
Seek to some point in a song. Seeks in current song if no position is given.
setVolume :: Int -> MPD ()Source
Set the volume.
volume :: Int -> MPD ()Source
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 ()Source
Stop playing.
Miscellaneous commands
clearerror :: MPD ()Source
Clear the current error message in status.
close :: MPD ()Source
Close an MPD connection.
commands :: MPD [String]Source
Retrieve a list of available commands.
notcommands :: MPD [String]Source
Retrieve a list of unavailable commands.
tagtypes :: MPD [String]Source
Retrieve a list of available song metadata.
urlhandlers :: MPD [String]Source
Retrieve a list of supported urlhandlers.
password :: String -> MPD ()Source
Send password to server to authenticate session. Password is sent as plain text.
ping :: MPD ()Source
Check that the server is still responding.
reconnect :: MPD ()Source
Refresh a connection.
stats :: MPD StatsSource
Get server statistics.
status :: MPD StatusSource
Get the server's status.
Extensions/shortcuts
addMany :: Maybe String -> [String] -> MPD ()Source
Add a list of songs/folders to a playlist. Should be more efficient than running add many times.
deleteMany :: Maybe String -> [PLIndex] -> MPD ()Source
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 ()Source
Crop playlist. The bounds are inclusive. If Nothing or ID is passed the cropping will leave your playlist alone on that side.
prune :: MPD ()Source
Remove duplicate playlist entries.
lsdirsSource
:: Maybe Stringoptional path.
-> MPD [String]
List directories non-recursively.
lsfilesSource
:: Maybe Stringoptional path.
-> MPD [String]
List files non-recursively.
lsplaylists :: MPD [String]Source
List all playlists.
findArtist :: Artist -> MPD [Song]Source
Search the database for songs relating to an artist.
findAlbum :: Album -> MPD [Song]Source
Search the database for songs relating to an album.
findTitle :: Title -> MPD [Song]Source
Search the database for songs relating to a song title.
listArtists :: MPD [Artist]Source
List the artists in the database.
listAlbums :: Maybe Artist -> MPD [Album]Source
List the albums in the database, optionally matching a given artist.
listAlbum :: Artist -> Album -> MPD [Song]Source
List the songs in an album of some artist.
searchArtist :: Artist -> MPD [Song]Source
Search the database for songs relating to an artist using search.
searchAlbum :: Album -> MPD [Song]Source
Search the database for songs relating to an album using search.
searchTitle :: Title -> MPD [Song]Source
Search the database for songs relating to a song title.
getPlaylist :: MPD [Song]Source
Retrieve the current playlist. Equivalent to 'playlistinfo Nothing'.
toggle :: MPD ()Source
Toggles play/pause. Plays if stopped.
updateid :: [String] -> MPD IntegerSource
Like update, but returns the update job id.
Connections
withMPD :: MPD a -> IO (Response a)Source
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.
withMPDExSource
::
=> StringHost name.
-> IntegerPort number.
-> IO (Maybe String)An action that supplies passwords.
-> MPD aThe action to run.
-> IO (Response a)
Run an MPD action against a server.
Misc.
kill :: MPD ()Source
Kill the server. Obviously, the connection is then invalid.
throwMPD :: MPDError -> MPD ()Source
Throw an exception.
catchMPD :: MPD a -> (MPDError -> MPD a) -> MPD aSource
Catch an exception from an action.
Produced by Haddock version 2.3.0