View Source Mpdex (mpdex v1.0.3)
Elixir client for Music Player Daemon (MPD).
Mpdex can be used to send commands to MPD, parse responses, manipulate play queue and playlists as well as to receive notifications about status and play queue changes.
Link to this section Summary
Functions
Adds URI to the playlist. Automatically creates playlist if it does not exist.
Adds URI to the queue. If URI is directory it will be added recursively. Otherwise single file or URL is added.
Seeks backward current song to the position time (in seconds; fractions allowed) relative to current position.
Returns a specification to start this module under a supervisor.
Clears the queue.
Clears the playlist.
Sets crossfading between songs.
Deletes playlist.
Deletes song at the given position from the playlist.
Seeks forward current song to the position time (in seconds; fractions allowed) relative to the current position.
Gets the content of the playlist.
Returns a list of music DB entries in the given URI.
Loads the whole playlist into the play queue.
Moves song in the playlist from the position from
to the position
to
.
Moves a song or range of songs to the given position.
Plays next song in the queue.
Pauses playback.
Begins playing the playlist at song position or with song ID.
Gets saved playlists.
Plays previous song in the queue.
Returns content of the queue.
Turns random off.
Turns random on.
Deletes song or range of songs from the queue.
Renames the playlist list_name
to the new_name
.
Turns repeat off.
Turns repeat on.
Resumes playback.
Saves the current play queue to the new playlist.
Seeks current song to the position time (in seconds; fractions allowed).
Shuffles the queue.
Mpdex GenServer start_link options
Returns statistics.
Returns current playback status.
Stops playing
Subscribes client process to MPD notifications
Updates MPD's music DB from the given URI.
Sets playback volume (from 0 to 100).
Link to this section Functions
Adds URI to the playlist. Automatically creates playlist if it does not exist.
Adds URI to the queue. If URI is directory it will be added recursively. Otherwise single file or URL is added.
Seeks backward current song to the position time (in seconds; fractions allowed) relative to current position.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Clears the queue.
Clears the playlist.
Sets crossfading between songs.
Deletes playlist.
Deletes song at the given position from the playlist.
Seeks forward current song to the position time (in seconds; fractions allowed) relative to the current position.
Gets the content of the playlist.
examples
Examples
Mpdex.get(mpd, "Radio")
{:ok,
[
%{
file: "https://naxidigital-classic128ssl.streaming.rs:8032#Naxi Classic",
metadata: %{
album: "Unknown",
artist: "Unknown",
time: 0,
title: "https://naxidigital-classic128ssl.streaming.rs:8032#Naxi Classic",
undefined: ""
}
},
%{
file: "https://naxidigital-cafe128ssl.streaming.rs:8022#Naxi Cafe Radio",
metadata: %{
album: "Unknown",
artist: "Unknown",
time: 0,
title: "https://naxidigital-cafe128ssl.streaming.rs:8022#Naxi Cafe Radio",
undefined: ""
}
}
]}
Returns a list of music DB entries in the given URI.
Loads the whole playlist into the play queue.
Moves song in the playlist from the position from
to the position
to
.
Moves a song or range of songs to the given position.
It accepts following options:
:start
- start position:end
- end position (song onend
position is excluded):to
- position to which songs will be moved
If both arguments are given all songs in the range will be
moved, otherwise moves song on the position :start
.
examples
Examples
Mpdex.move_song_in_queue(mpd, start: 1, to: 0)
{:ok, "OK\n"}
Mpdex.move_song_in_queue(mpd, start: 0, end: 3, to: 5)
{:ok, "OK\n"}
Plays next song in the queue.
Pauses playback.
Begins playing the playlist at song position or with song ID.
examples
Examples
Mpdex.play(:position, 2)
Mpdex.play(:id, 23)
Gets saved playlists.
examples
Examples
Mpdex.playlists(mpd)
{:ok,
[
%{last_modified: ~U[2022-08-10 11:52:13Z], playlist: "Radio"},
%{last_modified: ~U[2022-08-14 11:42:29Z], playlist: "Classic"}
]}
Plays previous song in the queue.
Returns content of the queue.
examples
Examples
Mpdex.queue(mpd)
{:ok,
[
%{
file: "https://naxidigital-cafe128ssl.streaming.rs:8022#Naxi Cafe Radio",
metadata: %{
album: "Unknown",
artist: "Unknown",
id: "1",
name: "NAXI CAFE RADIO (NAXI,Belgrade,Serbia, NAXI,Beograd,Srbija) - 128k",
position: 0,
time: 0,
title: "https://naxidigital-cafe128ssl.streaming.rs:8022#Naxi Cafe Radio",
undefined: ""
}
},
%{
file: "Classic/radetzky-march.mp3",
metadata: %{
album: "The Wedding Collection 1",
artist: "Various",
duration: 178.04,
genre: "Blues",
id: "2",
last_modified: ~U[2012-01-29 12:56:50Z],
position: 1,
time: 178,
title: "Radetzky March op. 228/Johann",
undefined: ["OK", ""]
}
}
]}
Turns random off.
Turns random on.
Deletes song or range of songs from the queue.
It accepts following options:
:start
- start position:end
- end position (exclusive)
If both arguments are given all songs in the range will be
removed, otherwise removes song on the position :start
.
examples
Examples
# deletes song on position 1
Mpdex.remove_from_queue(mpd, start: 1)
{:ok, "OK\n"}
# deletes songs 0, 1 and 2
Mpdex.remove_from_queue(mpd, start: 0, end: 3)
{:ok, "OK\n"}
Renames the playlist list_name
to the new_name
.
Turns repeat off.
Turns repeat on.
Resumes playback.
Saves the current play queue to the new playlist.
Seeks current song to the position time (in seconds; fractions allowed).
Shuffles the queue.
It accepts the following options:
:start
- start of range to be shuffled:end
- end of range to be shuffled
Without options shuffles entire queue.
Mpdex GenServer start_link options
:host
- host IP where MPD is running (default 127.0.0.1):port
- integer port number on which MPD listenes for connections (default 6600):name
- GenServer name
examples
Examples
{:ok, mpd} = Mpdex.start_link(host: "10.0.0.1", port: 6600)
Returns statistics.
examples
Examples
Mpdex.statistics(mpd)
%{
albums: "78",
artists: "216",
db_playtime: "291742",
db_update: "1660465475",
playtime: "20034",
songs: "1140",
uptime: "25174"
}
Returns current playback status.
examples
Examples
Mpdex.status(mpd)
%{
audio: [samplerate: "44100", bits: "24", channels: "2"],
bitrate: "128",
consume: "0",
elapsed: "20109.183",
mixrampdb: "0.000000",
nextsong: "1",
nextsongid: "2",
playlist: "4",
playlistlength: "2",
random: "0",
repeat: "0",
single: "0",
song: "0",
songid: "1",
state: "play",
time: "20109:0",
volume: "16"
}
Stops playing
Subscribes client process to MPD notifications
Updates MPD's music DB from the given URI.
Sets playback volume (from 0 to 100).