|
Network.MPD | Stability | alpha | Maintainer | Joachim Fasting <joachim.fasting@gmail.com> |
|
|
|
|
|
Description |
An MPD client library. MPD is a daemon for playing music that is
controlled over a network socket. Its site is at http://www.musicpd.org/.
To avoid name clashes with the standard Prelude functions, do:
import qualified Network.MPD as MPD
|
|
Synopsis |
|
class (Monad m, MonadError MPDError m) => MonadMPD m where | | | data MPD a | | | | | | type Response = Either MPDError | | type Host = String | | type Port = Integer | | type Password = String | | withMPD :: MPD a -> IO (Response a) | | withMPDEx :: Host -> Port -> Password -> MPD a -> IO (Response a) | | type Artist = String | | type Album = String | | type Title = String | | type PlaylistName = String | | type Path = String | | | | data ObjectType = SongObj | | type Seconds = Integer | | | | | | | | | | data Count = Count {} | | defaultCount :: Count | | data Device = Device {} | | defaultDevice :: Device | | data Stats = Stats {} | | defaultStats :: Stats | | data Song = Song {} | | defaultSong :: Song | | data Status = Status {} | | defaultStatus :: Status | | data Query | | (=?) :: Meta -> String -> Query | | (<&>) :: Query -> Query -> Query | | anything :: Query | | clearError :: MonadMPD m => m () | | currentSong :: (Functor m, MonadMPD m) => m (Maybe Song) | | idle :: MonadMPD m => m [Subsystem] | | noidle :: MonadMPD m => m () | | status :: MonadMPD m => m Status | | stats :: MonadMPD m => m Stats | | consume :: MonadMPD m => Bool -> m () | | crossfade :: MonadMPD m => Seconds -> m () | | random :: MonadMPD m => Bool -> m () | | repeat :: MonadMPD m => Bool -> m () | | setVolume :: MonadMPD m => Int -> m () | | single :: MonadMPD m => Bool -> m () | | replayGainMode :: MonadMPD m => ReplayGainMode -> m () | | replayGainStatus :: MonadMPD m => m [String] | | next :: MonadMPD m => m () | | pause :: MonadMPD m => Bool -> m () | | play :: MonadMPD m => Maybe PLIndex -> m () | | previous :: MonadMPD m => m () | | seek :: MonadMPD m => Maybe PLIndex -> Seconds -> m () | | stop :: MonadMPD m => m () | | add :: MonadMPD m => Path -> m [Path] | | add_ :: MonadMPD m => Path -> m () | | addId :: MonadMPD m => Path -> Maybe Integer -> m Integer | | clear :: MonadMPD m => m () | | delete :: MonadMPD m => PLIndex -> m () | | move :: MonadMPD m => PLIndex -> Integer -> m () | | playlist :: MonadMPD m => m [(PLIndex, Path)] | | playlistFind :: MonadMPD m => Query -> m [Song] | | playlistInfo :: MonadMPD m => Maybe (Either PLIndex (Int, Int)) -> m [Song] | | playlistSearch :: MonadMPD m => Query -> m [Song] | | plChanges :: MonadMPD m => Integer -> m [Song] | | plChangesPosId :: MonadMPD m => Integer -> m [(PLIndex, PLIndex)] | | shuffle :: MonadMPD m => Maybe (Int, Int) -> m () | | swap :: MonadMPD m => PLIndex -> PLIndex -> m () | | listPlaylist :: MonadMPD m => PlaylistName -> m [Path] | | listPlaylistInfo :: MonadMPD m => PlaylistName -> m [Song] | | listPlaylists :: MonadMPD m => m [PlaylistName] | | load :: MonadMPD m => PlaylistName -> m () | | playlistAdd :: MonadMPD m => PlaylistName -> Path -> m [Path] | | playlistAdd_ :: MonadMPD m => PlaylistName -> Path -> m () | | playlistClear :: MonadMPD m => PlaylistName -> m () | | playlistDelete :: MonadMPD m => PlaylistName -> Integer -> m () | | playlistMove :: MonadMPD m => PlaylistName -> Integer -> Integer -> m () | | rename :: MonadMPD m => PlaylistName -> PlaylistName -> m () | | rm :: MonadMPD m => PlaylistName -> m () | | save :: MonadMPD m => PlaylistName -> m () | | count :: MonadMPD m => Query -> m Count | | find :: MonadMPD m => Query -> m [Song] | | findAdd :: MonadMPD m => Query -> m () | | list :: MonadMPD m => Meta -> Query -> m [String] | | listAll :: MonadMPD m => Path -> m [Path] | | listAllInfo :: MonadMPD m => Path -> m [Either Path Song] | | lsInfo :: MonadMPD m => Path -> m [Either Path Song] | | search :: MonadMPD m => Query -> m [Song] | | update :: MonadMPD m => [Path] -> m () | | rescan :: MonadMPD m => [Path] -> m () | | stickerGet :: MonadMPD m => ObjectType -> String -> String -> m [String] | | stickerSet :: MonadMPD m => ObjectType -> String -> String -> String -> m () | | stickerDelete :: MonadMPD m => ObjectType -> String -> String -> m () | | stickerList :: MonadMPD m => ObjectType -> String -> m [(String, String)] | | stickerFind :: MonadMPD m => ObjectType -> String -> String -> m [(String, String)] | | close :: MonadMPD m => m () | | kill :: MonadMPD m => m () | | password :: MonadMPD m => String -> m () | | ping :: MonadMPD m => m () | | disableOutput :: MonadMPD m => Int -> m () | | enableOutput :: MonadMPD m => Int -> m () | | outputs :: MonadMPD m => m [Device] | | commands :: MonadMPD m => m [String] | | notCommands :: MonadMPD m => m [String] | | tagTypes :: MonadMPD m => m [String] | | urlHandlers :: MonadMPD m => m [String] | | decoders :: MonadMPD m => m [(String, [(String, String)])] | | addMany :: MonadMPD m => PlaylistName -> [Path] -> m () | | deleteMany :: MonadMPD m => PlaylistName -> [PLIndex] -> m () | | complete :: MonadMPD m => String -> m [Either Path Song] | | crop :: MonadMPD m => Maybe PLIndex -> Maybe PLIndex -> m () | | prune :: MonadMPD m => m () | | lsDirs :: MonadMPD m => Path -> m [Path] | | lsFiles :: MonadMPD m => Path -> m [Path] | | lsPlaylists :: MonadMPD m => m [PlaylistName] | | listArtists :: MonadMPD m => m [Artist] | | listAlbums :: MonadMPD m => Maybe Artist -> m [Album] | | listAlbum :: MonadMPD m => Artist -> Album -> m [Song] | | getPlaylist :: MonadMPD m => m [Song] | | toggle :: MonadMPD m => m () | | updateId :: MonadMPD m => [Path] -> m Integer | | volume :: MonadMPD m => Int -> m () |
|
|
|
Basic data types
|
|
|
A typeclass to allow for multiple implementations of a connection
to an MPD server.
| | Methods | | | Instances | |
|
|
|
The main implementation of an MPD client. It actually connects
to a server and interacts with it.
To use the error throwing/catching capabilities:
import Control.Monad.Error (throwError, catchError)
To run IO actions within the MPD monad:
import Control.Monad.Trans (liftIO)
| Instances | |
|
|
|
The MPDError type is used to signal errors, both from the MPD and
otherwise.
| Constructors | NoMPD | MPD not responding
| TimedOut | The connection timed out
| Unexpected String | MPD returned an unexpected response.
This is a bug, either in the library or
in MPD itself.
| Custom String | Used for misc. errors
| ACK ACKType String | ACK type and a message from the
server
|
| Instances | |
|
|
|
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)
|
| Instances | |
|
|
|
A response is either an MPDError or some result.
|
|
|
|
|
|
|
|
Connections
|
|
|
A wrapper for withMPDEx that uses 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" the password
will be supplied as well.
Examples:
withMPD $ play Nothing
withMPD $ add_ "tool" >> play Nothing >> currentSong
|
|
|
The most configurable API for running an MPD action.
|
|
Command related data types
|
|
|
|
|
|
|
|
|
Used for commands which require a playlist name.
If empty, the current playlist is used.
|
|
|
Used for commands which require a path within the database.
If empty, the root path is used.
|
|
|
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 | |
|
|
|
Object types.
| Constructors | | Instances | |
|
|
|
|
|
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 | |
|
|
|
Represents the different playback states.
| Constructors | | Instances | |
|
|
|
Represents the various MPD subsystems.
| Constructors | Database | The song database
| Update | Database updates
| StoredPlaylist | Stored playlists
| Playlist | The current playlist
| Player | The player
| Mixer | The volume mixer
| Output | Audio outputs
| Options | Playback options
|
| Instances | |
|
|
|
Constructors | Off | Disable replay gain
| TrackMode | Per track mode
| AlbumMode | Per album mode
|
| Instances | |
|
|
|
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 | |
|
|
|
|
|
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 | |
|
|
|
|
|
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 | |
|
|
|
|
|
Represents a single song item.
| Constructors | Song | Auxiliary song fields
| |
| Instances | |
|
|
|
|
|
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 | The number of items in the current playlist.
| stSongPos :: Maybe PLIndex | Current song's position in the playlist.
| stSongID :: Maybe PLIndex | Current song's playlist ID.
| stNextSongPos :: Maybe PLIndex | Next song's position in the playlist.
| stNextSongID :: Maybe PLIndex | Next 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).
| stSingle :: Bool | If True, MPD will play only one song and stop after finishing it.
| stConsume :: Bool | If True, a song will be removed after it has been played.
| stError :: String | Last error message (if any).
|
|
| Instances | |
|
|
|
|
Query interface
|
|
|
An interface for creating MPD queries.
For example, to match any song where the value of artist is "Foo", we
use:
Artist =? "Foo"
We can also compose queries, thus narrowing the search. For example, to
match any song where the value of artist is "Foo" and the value of album
is "Bar", we use:
Artist =? "Foo" <&> Album =? "Bar"
| Instances | |
|
|
|
Create a query.
|
|
|
Combine queries.
|
|
|
An empty query. Matches anything.
|
|
Querying MPD's status
|
|
|
Clear the current error message in status.
|
|
|
Get the currently playing song.
|
|
|
Wait until there is a noteworthy change in one or more of MPD's
susbystems. Note that running this command will block until either idle
returns or is cancelled by noidle.
|
|
|
Cancel idle.
|
|
|
Get the server's status.
|
|
|
Get server statistics.
|
|
Playback options
|
|
|
Set consume mode
|
|
|
Set crossfading between songs.
|
|
|
Set random playing.
|
|
|
Set repeating.
|
|
|
Set the volume (0-100 percent).
|
|
|
Set single mode
|
|
|
Set the replay gain mode.
|
|
|
Get the replay gain options.
|
|
Controlling playback
|
|
|
Play the next song.
|
|
|
Pause playing.
|
|
|
Begin/continue playing.
|
|
|
Play the previous song.
|
|
|
Seek to some point in a song.
Seeks in current song if no position is given.
|
|
|
Stop playing.
|
|
The current playlist
|
|
|
Like add_ but returns a list of the files added.
|
|
|
Add a song (or a whole directory) to the current playlist.
|
|
|
|
|
|
Clear the current playlist.
|
|
|
Remove a song from the current playlist.
|
|
|
Move a song to a given position in the current playlist.
|
|
|
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, please use playlistInfo
instead.
|
|
|
Search for songs in the current playlist with strict matching.
|
|
|
Retrieve metadata for songs in the current playlist.
|
|
|
Search case-insensitively with partial matches for songs in the
current playlist.
|
|
|
Retrieve a list of changed songs currently in the playlist since
a given playlist version.
|
|
|
Like plChanges but only returns positions and ids.
|
|
|
|
|
|
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.
|
|
Stored playlist
|
|
|
Retrieve a list of files in a given playlist.
|
|
|
Retrieve metadata for files in a given playlist.
|
|
|
Retreive a list of stored playlists.
|
|
|
Load an existing playlist.
|
|
|
Like playlistAdd but returns a list of the files added.
|
|
|
Add a song (or a whole directory) to a stored playlist.
Will create a new playlist if the one specified does not already exist.
|
|
|
Clear a playlist. If the specified playlist does not exist, it will be
created.
|
|
|
|
|
|
Move a song to a given position in the playlist specified.
|
|
|
|
|
|
Delete existing playlist.
|
|
|
Save the current playlist.
|
|
The music database
|
|
|
Count the number of entries matching a query.
|
|
|
Search the database for entries exactly matching a query.
|
|
|
Adds songs matching a query to the current playlist.
|
|
|
|
|
|
List the songs (without metadata) in a database directory recursively.
|
|
|
Recursive lsInfo.
|
|
|
Non-recursively list the contents of a database directory.
|
|
|
Search the database using case insensitive matching.
|
|
|
Update the server's database.
If no paths are given, all paths will be scanned.
Unreadable or non-existent paths are silently ignored.
|
|
|
Like update but also rescans unmodified files.
|
|
Stickers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Connection
|
|
|
Close the connection.
|
|
|
Kill the server. Obviously, the connection is then invalid.
|
|
|
Send password to server to authenticate session.
Password is sent as plain text.
|
|
|
Check that the server is still responding.
|
|
Audio output devices
|
|
|
Turn off an output device.
|
|
|
Turn on an output device.
|
|
|
Retrieve information for all output devices.
|
|
Reflection
|
|
|
Retrieve a list of available commands.
|
|
|
Retrieve a list of unavailable (due to access restrictions) commands.
|
|
|
Retrieve a list of available song metadata.
|
|
|
Retrieve a list of supported urlhandlers.
|
|
|
Retreive a list of decoder plugins with associated suffix and mime types.
|
|
Extensions/shortcuts
|
|
|
Add a list of songs/folders to a playlist.
Should be more efficient than running add many times.
|
|
|
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).
|
|
|
Returns all songs and directories that match the given partial
path name.
|
|
|
Crop playlist.
The bounds are inclusive.
If Nothing is passed the cropping will leave your playlist alone
on that side.
Using ID will automatically find the absolute playlist position and use
that as the cropping boundary.
|
|
|
Remove duplicate playlist entries.
|
|
|
List directories non-recursively.
|
|
|
List files non-recursively.
|
|
|
List all playlists.
|
|
|
List the artists in the database.
|
|
|
List the albums in the database, optionally matching a given
artist.
|
|
|
List the songs in an album of some artist.
|
|
|
Retrieve the current playlist.
Equivalent to playlistinfo Nothing.
|
|
|
Toggles play/pause. Plays if stopped.
|
|
|
Like update, but returns the update job id.
|
|
|
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.
|
|
Produced by Haddock version 2.6.1 |