MphpD
v1.1.0-rc.3 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

- ##### $mphpd

- ##### $name

#### Returns `mixed`

### exists

Function to determine if the specified playlist exists.

    Playlist::exists() : bool

#### Parameters

None.

#### Returns `bool`

bool `true` if it exists, otherwise `false`.

### get_songs

Returns a list of all songs in the specified playlist.

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

#### Parameters

- ##### $metadata

  If set to `true` metadata like duration, last-modified,... will be included.

#### Returns `mixed`

array|false `array` of associative Arrays containing song information on success or `false` on failure.

### load

Loads the specified playlist into the Queue.

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

#### Parameters

- ##### $range

  Range. If specified only the requested portion of the playlist is loaded. Starts at 0.

- ##### $pos

  Specifies where the songs will be inserted into the queue.

  Can be relative if prefixed with + or -

#### Returns `bool`

bool `true` on success and `false` on failure.

### add

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

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

#### Parameters

- ##### $uri

  Relative file path or other supported URIs.

- ##### $pos

  Specifies where the songs will be inserted into the playlist. Can be relative if prefixed with + or -

#### Returns `bool`

bool `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

- ##### $filter

- ##### $sort

- ##### $window

- ##### $position

#### Returns `bool`

bool

### clear

Removes all songs from the specified playlist.

    Playlist::clear() : bool

#### Parameters

None.

#### Returns `bool`

bool `true` on success and `false` on failure.

### remove_song

Deletes `$songpos` from the specified playlist.

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

#### Parameters

- ##### $songpos

  Position of the song or Range

#### Returns `bool`

bool `true` on success and `false` on failure.

### 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

- ##### $from

  Current song position

- ##### $to

  New song position

#### Returns `bool`

bool `true` on success and `false` on failure.

### rename

Renames the specified playlist to `$new_name`

    Playlist::rename(string $new_name) : bool

#### Parameters

- ##### $new_name

  New playlist name

#### Returns `bool`

bool `true` on success and `false` on failure.

### delete

Removes the specified playlist from the playlist directory.

    Playlist::delete() : bool

#### Parameters

None.

#### Returns `bool`

bool `true` on success and `false` on failure.

### save

Saves the queue to the specified playlist in the playlist directory

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

#### Parameters

- ##### $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 and `false` on failure.

© 2023 Florian Faber