예제 #1
0
 /**
  * Given a Plex server library item, this method plays the given item on
  * the Plex client.
  *
  * @param Plex_Server_Library_ItemAbstract $item The item to be played.
  * @param integer $viewOffset The point from which to play the item in
  * milliseconds.
  *
  * @uses Plex_Server_Library::ENDPOINT_LIBRARY
  * @uses Plex_Server_Library::ENDPOINT_METADATA
  * @uses Plex_Server_Library_ItemAbstract::getRatingKey()
  * @uses Plex_Client::getServer()
  * @uses Plex_Server::getBaseUrl()
  * @uses Plex_Client_ControllerAbstract::executeCommand()
  *
  * @return void
  */
 public function playMedia(Plex_Server_Library_ItemAbstract $item, $viewOffset = NULL)
 {
     $key = sprintf('/%s/%s/%d', Plex_Server_Library::ENDPOINT_LIBRARY, Plex_Server_Library::ENDPOINT_METADATA, $item->getRatingKey());
     $params = array('key' => $key, 'path' => sprintf('%s%s', $this->getServer()->getBaseUrl(), $key));
     if ($viewOffset) {
         $params['viewOffset'] = $viewOffset;
     }
     $this->executeCommand($params);
 }
예제 #2
0
파일: Library.php 프로젝트: bonvga/php-plex
 /**
  * Generic way of requesting Plex library items.
  *
  * @uses Plex_MachineAbstract::$name
  * @uses Plex_MachineAbstract::$address
  * @uses Plex_MachineAbstract::$port
  * @uses Plex_MachineAbstract::makeCall()
  * @uses Plex_Server_Library::buildUrl()
  * @uses Plex_Server_Library_ItemAbstract::factory()
  * @uses Plex_Server_Library_ItemInterface::setAttributes()
  *
  * return Plex_Server_Library_Item[] An array of plex library items.
  */
 protected function getItems($endpoint)
 {
     $items = array();
     $itemArray = $this->makeCall($this->buildUrl($endpoint));
     foreach ($itemArray as $attribute) {
         // Not all attributes at this point have a 'type.' Sometimes they
         // represent a different sort of list like 'All episodes.' In this
         // case we skip it by checking the integrity of the 'type' index.
         // If there is no type index then it is not an item.
         if (isset($attribute['type'])) {
             $item = Plex_Server_Library_ItemAbstract::factory($attribute['type'], $this->name, $this->address, $this->port);
             $item->setAttributes($attribute);
             $items[] = $item;
         }
     }
     return $items;
 }
예제 #3
0
 /**
  * Sets an array of attribues, if they exist, to the corresponding class
  * member.
  * 
  * @param array $attribute An array of item attributes as passed back by the
  * Plex HTTP API.
  *
  * @uses Plex_Server_Library_ItemGrandparentAbstract::setArt()
  * @uses Plex_Server_Library_ItemGrandparentAbstract::setLeafCount()
  * @uses Plex_Server_Library_ItemGrandparentAbstract::setViewedLeafCount()
  * @uses Plex_Server_Library_ItemGrandparentAbstract::setYear()
  * @uses Plex_Server_Library_ItemGrandparentAbstract::setRating()
  * @uses Plex_Server_Library_ItemGrandparentAbstract::setContentRating()
  *
  * @return void
  */
 public function setAttributes($attribute)
 {
     parent::setAttributes($attribute);
     if (isset($attribute['art'])) {
         $this->setArt($attribute['art']);
     }
     if (isset($attribute['leafCount'])) {
         $this->setLeafCount($attribute['leafCount']);
     }
     if (isset($attribute['viewedLeafCount'])) {
         $this->setViewedLeafCount($attribute['viewedLeafCount']);
     }
     if (isset($attribute['year'])) {
         $this->setYear($attribute['year']);
     }
     if (isset($attribute['rating'])) {
         $this->setRating($attribute['rating']);
     }
     if (isset($attribute['contentRating'])) {
         $this->setContentRating($attribute['contentRating']);
     }
 }