MphpD
v1.2.3 Documentation GitHub

# Player

This subclass is used to control MPDs playback. You may also want to have a look at the MPD documentation.

    MphpD::player() : Player

## Methods

### __construct

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

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

#### Parameters

- ##### $mphpd

#### Returns `mixed`

### consume

Enables/Disables the consume mode

    Player::consume(int $state) : bool

#### Parameters

- ##### $state

  One of the following:

  - `MPD_STATE_ON` - Enables consume mode

  - `MPD_STATE_OFF` - Disables consume mode

  - `MPD_STATE_ONESHOT` - Enables consume mode for a single song. This is only supported on MPD version 0.24 and newer.

#### Returns `bool`

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

### crossfade

Sets crossfade to `$seconds` seconds.

    Player::crossfade(int $seconds) : bool

#### Parameters

- ##### $seconds

  Crossfade duration in seconds.

#### Returns `bool`

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

### mixramp_db

Sets the threshold at which songs will be overlapped. See https://mpd.readthedocs.io/en/latest/user.html#mixramp for more information

    Player::mixramp_db(int $dB) : bool

#### Parameters

- ##### $dB

#### Returns `bool`

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

### mixramp_delay

Additional time subtracted from the overlap calculated by mixrampdb. A value of `nan` disables MixRamp overlapping and falls back to crossfading. See MixRamp.

    Player::mixramp_delay(float $seconds) : bool

#### Parameters

- ##### $seconds

#### Returns `bool`

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

### random

Specified if MPD should play the queue in random order

    Player::random(int $state) : bool

#### Parameters

- ##### $state

  Either `MPD_STATE_OFF` or `MPD_STATE_ON`

#### Returns `bool`

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

### repeat

Specifies if MPD should start from the top again when reaching the end of the queue.

    Player::repeat(int $state) : bool

#### Parameters

- ##### $state

  Either `MPD_STATE_OFF` or `MPD_STATE_ON`

#### Returns `bool`

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

### volume

Sets volume to `$volume` or returns the current volume if `$volume` is omitted.

    Player::volume(int $volume = -1) : mixed

#### Parameters

- ##### $volume

  If specified the current volume is set to `$volume`.

  If omitted the current volume is returned.

#### Returns `mixed`

int|bool `true` on success, `false` on failure and `int` if `$volume` was omitted.

### single

Enables/Disables the single-mode. If enabled MPD will play the same song over and over.

    Player::single(int $state) : bool

#### Parameters

- ##### $state

  One of the following:

  - `MPD_STATE_ON` - Enables single mode

  - `MPD_STATE_OFF` - Disables single mode

  - `MPD_STATE_ONESHOT` - Enables single mode for only a single time. This is only supported on MPD version 0.21 and newer.

#### Returns `bool`

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

### replay_gain_mode

Specifies whether MPD shall adjust the volume of songs played using ReplayGain tags.

    Player::replay_gain_mode(string $mode) : bool

#### Parameters

- ##### $mode

  One of `off`, `track`, `album`, `auto`

#### Returns `bool`

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

### replay_gain_status

Get the current replay gain. Currently only the variable `replay_gain_mode` is returned by MPD.

    Player::replay_gain_status() : mixed

#### Parameters

None.

#### Returns `mixed`

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

### current_song

Returns an associative `array` containing information about the currently playing song.

    Player::current_song() : mixed

#### Parameters

None.

#### Returns `mixed`

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

### next

Plays the next song in the Queue

    Player::next() : bool

#### Parameters

None.

#### Returns `bool`

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

### pause

Pause or resume playback.

    Player::pause(?int $state = null) : bool

#### Parameters

- ##### $state

  Optional. One of the following:

  - `MPD_STATE_ON` - Pause

  - `MPD_STATE_OFF` - Resume

  If omitted or `null` the pause state is toggled.

#### Returns `bool`

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

### play

Plays the song position `$pos` in the Queue

    Player::play(int $pos) : bool

#### Parameters

- ##### $pos

  Song position starting at 0.

#### Returns `bool`

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

### play_id

Begins playing the playlist at song `$id`

    Player::play_id(int $id) : bool

#### Parameters

- ##### $id

  ID of the song.

#### Returns `bool`

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

### previous

Plays the previous song in the Queue

    Player::previous() : bool

#### Parameters

None.

#### Returns `bool`

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

### seek

Seeks to `$seconds` of song `$songpos` in the Queue.

    Player::seek(int $songpos, float $time) : bool

#### Parameters

- ##### $songpos

  Queue-position of the song.

- ##### $time

  Seconds to seek to.

#### Returns `bool`

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

### seek_id

Seeks to `$seconds` of song `$songid`. Same as `Player::seek()` but with a song ID instead of a position.

    Player::seek_id(int $songid, float $time) : bool

#### Parameters

- ##### $songid

  ID of the song.

- ##### $time

  Seconds to seek to.

#### Returns `bool`

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

### seek_cur

Seeks to `$seconds` of the current song.

    Player::seek_cur( $time) : bool

#### Parameters

- ##### $time

  If prefixed with `+` or `-` the time is relative to the current playing position.

#### Returns `bool`

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

### stop

Stops playing.

    Player::stop() : bool

#### Parameters

None.

#### Returns `bool`

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

© 2023 Florian Faber