MphpD
v1.0.0-rc.2 Documentation GitHub

# Playlist

Subclass to interact with stored Playlists.

    MphpD::playlist(string $name) : Playlist

## Methods

### __construct

This class is not intended for direct usage. Use MphpD::playlist() instead to retrieve an instance of this class.

    Playlist::__construct(FloFaber\MphpD\MphpD $mphpd, string $name) : mixed

#### Parameters

@param \MphpD $mphpd

@param string $name

#### Returns `mixed`

### exists

Function to determine if the specified playlist exists.

    Playlist::exists() : bool

#### Parameters

None.

#### Returns `bool`

bool True if it exists. False if it doesn't.

### get_songs

Returns a list of all songs in the specified playlist.

    Playlist::get_songs(bool $metadata = ) : array

#### Parameters

@param bool $metadata If set to true metadata like duration, last-modified,... will be included.

#### Returns `array`

array|false On success returns an Array of associative Arrays containing song information. False on failure.

### load

Loads the specified playlist into the Queue.

    Playlist::load(array $range = [],  $pos = '') : bool

#### Parameters

@param array $range Range. If specified only the requested portion of the playlist is loaded. Starts at 0.

@param int|string $pos The $pos parameter specifies where the songs will be inserted into the queue.

Can be relative if prefixed with + or -

#### Returns `bool`

bool

### add

Adds $uri to the specified playlist at position $pos.

    Playlist::add(string $uri,  $pos = '') : bool

#### Parameters

@param string $uri Relative file path or other supported URIs.

@param int|string $pos Specifies where the songs will be inserted into the playlist. Can be relative if prefixed with + or -

#### Returns `bool`

bool Returns true on success and false on failure.

### add_search

Search for songs using Filter and add them into the Playlist at position $pos.

    Playlist::add_search(FloFaber\MphpD\Filter $filter, string $sort = '', array $window = [], int $position = -1) : bool

#### Parameters

@param \Filter $filter

@param string $sort

@param array $window

@param int $position

#### Returns `bool`

bool

### clear

Removes all songs from the specified playlist.

    Playlist::clear() : bool

#### Parameters

None.

#### Returns `bool`

bool Returns true on success and false on failure.

### remove_song

Deletes $songpos from the specified playlist.

    Playlist::remove_song( $songpos = -1) : bool

#### Parameters

@param int|array $songpos Position of the song or Range

#### Returns `bool`

bool

### move_song

Moves the song at position $from in the specified playlist to the position $to.

    Playlist::move_song(int $from, int $to) : bool

#### Parameters

@param int $from

@param int $to

#### Returns `bool`

bool

### rename

Renames the specified playlist to $new_name

    Playlist::rename(string $new_name) : bool

#### Parameters

@param string $new_name New playlist name

#### Returns `bool`

bool Returns true on success and false on failure

### delete

Removes the specified playlist from the playlist directory.

    Playlist::delete() : bool

#### Parameters

None.

#### Returns `bool`

bool

### save

Saves the queue to the specified playlist in the playlist directory

    Playlist::save(int $mode = 1) : bool

#### Parameters

@param int $mode Optional. One of the following:

- MPD_MODE_CREATE: The default. Create a new playlist. Fails if a playlist with name $name already exists.

- MPD_MODE_APPEND: Append an existing playlist. Fails if a playlist with name $name doesn't already exist. Only supported on MPD v0.24 and newer.

- MPD_MODE_REPLACE: Replace an existing playlist. Fails if a playlist with name $name doesn't already exist. Only supported on MPD v0.24 and newer.

#### Returns `bool`

bool True on success. False on failure.

© 2023 Florian Faber