duncan3dc\Sonos\Controller::getState PHP Method

getState() public method

Get the current state of the group of speakers.
public getState ( ) : integer
return integer One of the class STATE_ constants
    public function getState()
    {
        $name = $this->getStateName();
        switch ($name) {
            case "STOPPED":
                return self::STATE_STOPPED;
            case "PLAYING":
                return self::STATE_PLAYING;
            case "PAUSED_PLAYBACK":
                return self::STATE_PAUSED;
            case "TRANSITIONING":
                return self::STATE_TRANSITIONING;
        }
        return self::STATE_UNKNOWN;
    }

Usage Example

 /**
  * Get the current playing attributes (stream/position/etc).
  *
  * @param Controller $controller The Controller to grab the state of
  *
  * @return static
  */
 protected function getState(Controller $controller)
 {
     $this->state = $controller->getState();
     $details = $controller->getStateDetails();
     $this->track = $details->queueNumber;
     $this->position = $details->position;
     return $this;
 }