createFromUri() public method

Create a new Track instance from a URI.
public createFromUri ( string $uri ) : duncan3dc\Sonos\Tracks\Track
$uri string The URI of the track
return duncan3dc\Sonos\Tracks\Track
Example #1
0
 /**
  * Add tracks to the queue.
  *
  * @param string[]|UriInterface[] $tracks An array where each element is either the URI of the tracks to add, or an object that implements the UriInterface
  * @param int $position The position to insert the tracks in the queue (zero-based), by default the tracks will be added to the end of the queue
  *
  * @return bool
  */
 public function addTracks(array $tracks, $position = null)
 {
     foreach ($tracks as &$track) {
         # If a simple uri has been passed then convert it to a Track instance
         if (is_string($track)) {
             $track = $this->trackFactory->createFromUri($track);
         }
         if (!$track instanceof UriInterface) {
             throw new \InvalidArgumentException("The addTracks() array must contain either string URIs or objects that implement \\duncan3dc\\Sonos\\Tracks\\UriInterface");
         }
     }
     unset($track);
     return $this->addUris($tracks, $position);
 }