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

@param \MphpD $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

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

@param int|string $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 Returns `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

@param string $uri Is always a single file or URL

@param int|string $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 Returns 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

@param \Filter $filter

@param string $sort

@param array $window

@param int $position

#### Returns `bool`

bool

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

@param \Filter $filter

@param string $sort

@param array $window

@param int $pos Optional. If specified the matched songs will be added to this position in the Queue.

#### Returns `bool`

bool

### clear

Clears the queue

    Queue::clear() : bool

#### Parameters

None.

#### Returns `bool`

bool Returns true on success and false on failure.

### delete

Deletes a song or a range of songs from the queue

    Queue::delete( $p) : bool

#### Parameters

@param int|array $p The song position or Range

#### Returns `bool`

bool

### delete_id

Deletes the song with ID $songid from the Queue

    Queue::delete_id(int $songid) : bool

#### Parameters

@param int $songid

#### Returns `bool`

bool

### move

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

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

#### Parameters

@param int|array $from Song position or Range

@param string $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

### move_id

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

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

#### Parameters

@param int $from

@param string $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 song).

#### Returns `bool`

bool

### find

Same as Queue::search but case-sensitive

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

#### Parameters

@param \Filter $filter

@param string $sort

@param array $window

#### Returns `mixed`

array|false

### get_id

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

    Queue::get_id(int $songid) : mixed

#### Parameters

@param int $songid

#### Returns `mixed`

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

### get

If $p is omitted returns an array of associative arrays containing information about songs in the Queue. If $p is specified returns an associative array containing the given songs information only.

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

#### Parameters

@param $p int|array Optional. Song Position or Range.

If omitted all songs in the queue will be returned.

#### Returns `array`

array|false Array on success. False on failure.

### search

Search the queue for matching songs.

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

#### Parameters

@param \Filter $filter The Filter.

@param string $sort If specified the results are sorted by the specified tag.

@param array $window If specified returns only the given portion.

#### Returns `mixed`

array|false Returns array on success and 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

@param int $version The current version can be retrieved with MphpD::status([ "playlist" ]).

@param int|array $range Position of song or Range

@param bool $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 Returns array on success and 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

@param int $priority Priority. 0-255.

@param int|array $range Position of song or Range

#### Returns `bool`

bool

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

@param int $priority

@param int $id

#### Returns `bool`

bool

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

@param int $songid

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

#### Returns `bool`

bool

### shuffle

Shuffle the Queue.

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

#### Parameters

@param array $range If specified only this portion will be shuffled.

#### Returns `bool`

bool

### swap

Swap two songs in Queue. By Position.

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

#### Parameters

@param int $songpos_1

@param int $songpos_2

#### Returns `bool`

bool

### swap_id

Swap two songs in Queue. By ID.

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

#### Parameters

@param int $songid_1

@param int $songid_2

#### Returns `bool`

bool

### add_tag_id

Adds a tag to the specified song

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

#### Parameters

@param int $songid

@param string $tag Tag name

@param string $value Tag value

#### Returns `bool`

bool

### clear_tag_id

Removes a tag from the specified song

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

#### Parameters

@param int $songid

@param string $tag Tag name

#### Returns `bool`

bool

© 2023 Florian Faber