MphpD
v1.2.2 Documentation GitHub

# Queue

Subclass to control the Queue.

    MphpD::queue() : Queue

## Methods

### __construct

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

    Queue::__construct(FloFaber\MphpD\MphpD $mphpd) : mixed

#### Parameters

- ##### $mphpd

#### Returns `mixed`

### add

Adds the file `$uri` to the queue (directories add recursively). `$uri` can also be a single file.

    Queue::add(string $uri,  $pos = -1) : bool

#### Parameters

- ##### $uri

  Can be a single file or folder. If connected via Unix socket you may add arbitrary local files (absolute paths)

- ##### $pos

  If set the song is inserted at the specified position. If the parameter starts with + or -, then it is relative to the current song. e.g. +0 inserts right after the current song and -0 inserts right before the current song (i.e. zero songs between the current song and the newly added song).

#### Returns `bool`

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

### add_id

Adds a song to the playlist (non-recursive) and returns the song id.

    Queue::add_id(string $uri,  $pos = -1) : mixed

#### Parameters

- ##### $uri

  Is always a single file or URL

- ##### $pos

  If set the song is inserted at the specified position. If the parameter starts with + or -, then it is relative to the current song. e.g. +0 inserts right after the current song and -0 inserts right before the current song (i.e. zero songs between the current song and the newly added song).

#### Returns `mixed`

int|false The song ID on success or `false` on failure.

### add_search

Same as `search()` but adds the songs into the Queue at position `$pos`.

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

#### Parameters

- ##### $filter

- ##### $sort

- ##### $window

- ##### $position

#### Returns `bool`

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

### add_find

Same as `find()` but this adds the matching song to the Queue.

    Queue::add_find(FloFaber\MphpD\Filter $filter, string $sort = '', array $window = [], int $pos = -1) : bool

#### Parameters

- ##### $filter

- ##### $sort

- ##### $window

- ##### $pos

  Optional. If specified the matched songs will be added to this position in the Queue.

#### Returns `bool`

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

### clear

Clears the queue

    Queue::clear() : bool

#### Parameters

None.

#### Returns `bool`

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

### delete

Deletes a song or a range of songs from the queue

    Queue::delete( $p) : bool

#### Parameters

- ##### $p

  The song position or Range

#### Returns `bool`

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

### delete_id

Deletes the song with ID `$songid` from the Queue

    Queue::delete_id(int $songid) : bool

#### Parameters

- ##### $songid

  The song ID

#### Returns `bool`

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

### move

Moves the song at `$from` to `$to` in the queue

    Queue::move( $from, string $to) : bool

#### Parameters

- ##### $from

  Song position or Range

- ##### $to

  If starting with + or -, then it is relative to the current song e.g. +0 moves to right after the current song and -0 moves to right before the current song (i.e. zero songs between the current song and the moved range).

#### Returns `bool`

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

### move_id

Moves the song with `$from` (songid) to `$to` (playlist index) in the queue.

    Queue::move_id(int $from, string $to) : bool

#### Parameters

- ##### $from

  Song ID

- ##### $to

  Playlist Index. If starting with + or -, then it is relative to the current song e.g. +0 moves to right after the current song and -0 moves to right before the current song (i.e. zero songs between the current song and the moved song).

#### Returns `bool`

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

### find

Same as Queue::search but case-sensitive

    Queue::find(FloFaber\MphpD\Filter $filter, string $sort = '', array $window = []) : mixed

#### Parameters

- ##### $filter

- ##### $sort

- ##### $window

#### Returns `mixed`

array|false `array` on success or `false` on failure.

### get_id

Returns an associative arrays containing information about the song with ID `$songid`.

    Queue::get_id(int $songid) : mixed

#### Parameters

- ##### $songid

  Song ID

#### Returns `mixed`

array|false Associative `array` containing song information or `false` on failure.

### get

Returns information about all or specific songs in the Queue.

    Queue::get( $p = -1) : mixed

#### Parameters

- ##### int|array

  Optional. Song Position or Range. If omitted returns an array of associative arrays containing information about all songs in the Queue. If specified returns an associative array containing the given songs information only.

#### Returns `mixed`

array|false `array` on success or `false` on failure. An empty `array` is returned if the queue is empty.

### search

Search the queue for matching songs.

    Queue::search(FloFaber\MphpD\Filter $filter, string $sort = '', array $window = []) : mixed

#### Parameters

- ##### $filter

  The Filter.

- ##### $sort

  If specified the results are sorted by the specified tag.

- ##### $window

  If specified returns only the given portion.

#### Returns `mixed`

array|false `array` on success or `false` on failure.

### changes

Returns an array of changed songs currently in the playlist since `$version`.

    Queue::changes(int $version,  $range = -1, bool $metadata = ) : mixed

#### Parameters

- ##### $version

  The current version can be retrieved with `MphpD::status([ "playlist" ])`.

- ##### $range

  Position of song or Range

- ##### $metadata

  If set to true the metadata will be included.

  If set to false only the position and ID of the changed songs will be returned.

#### Returns `mixed`

array|false `array` on success or `false` on failure.

### prio

Sets the priority of given songs to `$priority`. This only has effect when the `random`-mode is enabled. A higher priority means that it will be played first when `random` is enabled.

    Queue::prio(int $priority,  $range = -1) : bool

#### Parameters

- ##### $priority

  Priority 0-255.

- ##### $range

  Position of song or Range

#### Returns `bool`

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

### prio_id

Sets the priority of Song ID `$id` to $priority. This only has effect when the `random`-mode is enabled. A higher priority means that it will be played first when `random` is enabled.

    Queue::prio_id(int $priority, int $id) : bool

#### Parameters

- ##### $priority

  Priority 0-255.

- ##### $id

  Song ID.

#### Returns `bool`

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

### range_id

Set's the portion of the song that should be played. You can't edit the currently playing song!

    Queue::range_id(int $songid, array $range = []) : bool

#### Parameters

- ##### $songid

  Song ID.

- ##### $range

  Range. Start and End are offsets in seconds. If omitted the "play-range" will be removed from the song.

#### Returns `bool`

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

### shuffle

Shuffle the Queue.

    Queue::shuffle(array $range = []) : bool

#### Parameters

- ##### $range

  If specified only this portion will be shuffled.

#### Returns `bool`

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

### swap

Swap two songs in Queue. By Position.

    Queue::swap(int $songpos_1, int $songpos_2) : bool

#### Parameters

- ##### $songpos_1

- ##### $songpos_2

#### Returns `bool`

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

### swap_id

Swap two songs in Queue. By ID.

    Queue::swap_id(int $songid_1, int $songid_2) : bool

#### Parameters

- ##### $songid_1

  First song ID

- ##### $songid_2

  Second song ID

#### Returns `bool`

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

### add_tag_id

Adds a tag to the specified song

    Queue::add_tag_id(int $songid, string $tag, string $value) : bool

#### Parameters

- ##### $songid

  Song ID

- ##### $tag

  Tag name

- ##### $value

  Tag value

#### Returns `bool`

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

### clear_tag_id

Removes a tag from the specified song

    Queue::clear_tag_id(int $songid, string $tag) : bool

#### Parameters

- ##### $songid

  Song ID

- ##### $tag

  Tag name

#### Returns `bool`

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

© 2023 Florian Faber