Set Player Video
Does not validate whether or not YouTube video exists.


@param string $video Can be a URL or just the ID

@throws AudioPlayerException

@return $this
427655
public function video($video)
    {
        $oldSource = $this->source;
        $this->source = $video;

        $parsedURL = parse_url($video);

        // 1 thing, assume video.
        if (count($parsedURL) === 1) {
            $this->type = static::TYPE_VIDEO;
            $this->id = $parsedURL['path'];

            return $this;
        }

        // Youtu.be - Video
        if (strtolower($parsedURL['host']) == 'youtu.be') {
            $this->type = static::TYPE_VIDEO;
            $this->id = substr($parsedURL['path'], 1);

            return $this;
        }

        // Assume its a YouTube URL
        // check for /watch
        if (strtolower($parsedURL['path']) == '/watch') {
            $parsedQuery = explode('&', $parsedURL['query']);
            // Find v=
            foreach ($parsedQuery as $v) {
                if (substr(strtolower($v), 0, 2) == 'v=') {
                    $this->type = static::TYPE_VIDEO;
                    $this->id = substr($v, 2);

                    return $this;
                }
            }
        }

        // check for /v/
        if (substr(strtolower($parsedURL['path']), 0, 3) == '/v/') {
            $this->type = static::TYPE_VIDEO;
            $this->id = substr($parsedURL['path'], 0, 3);

            return $this;
        }

        $this->source = $oldSource;
        throw new AudioPlayerException('Could not identify video');
    }
562374
public function setPlayer($player)
    {
        self::$xml['player'] = '<media:player';

        $this->writeAttribute(
            $player,
            'player',
            'url',
            $this->validator,
            'validatePlayer',
            $this->exception,
            'Provided player URL is not a valid value.'
        );

        self::$xml['player'] .= ' />';

        return $this;
    }
2881
public function setReferenceId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->reference_id !== $v) {
            $this->reference_id = $v;
            $this->modifiedColumns[VideoTableMap::COL_REFERENCE_ID] = true;
        }

        if ($this->aReference !== null && $this->aReference->getId() !== $v) {
            $this->aReference = null;
        }

        return $this;
    }
1021157
public function isYoutube($video) {
        $playerurl = (is_string($video) ? $video :
            (isset($video['player']) ? $video['player'] : ''));
        return preg_match('~youtube\.com~i', $playerurl);
    }
34475
public function setDuration($duration)
    {
        if ($duration < 0 || $duration > 28800) {
            throw new Exception\GoogleVideoUrlException(
                sprintf(
                    'The parameter %s must be a valid duration.see http://support.google.com/webmasters/bin/answer.py?hl=en&answer=80472#4',
                    $duration
                )
            );
        }

        $this->duration = $duration;

        return $this;
    }
83124
public function setDescription($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->description !== $v) {
            $this->description = $v;
            $this->modifiedColumns[VideoTableMap::COL_DESCRIPTION] = true;
        }

        return $this;
    }
552171
public function setType($type)
    {
        switch($type)
        {
            case self::YOUTUBE:
                return new Services\Youtube();
                break;

            case self::VIMEO:
                return new Services\Vimeo();
                break;

            default:
                throw new \InvalidArgumentException("$type is not a valid video site");
        }
    }
1339880
public function setUrl($url) {
        if (!is_string($url)) throw new IllegalTypeException('Illegal type of parameter $url: '.gettype($url));

        // TODO: validate URL

        if (strpos($url, ' ') !== false)
            throw new InvalidArgumentException('Invalid argument $url: '.$url);

        $this->url = $url;
        return $this;
    }
135731
public function build(): SetPlaybackRateRequest
	{
		$instance = new SetPlaybackRateRequest();
		if ($this->playbackRate === null) {
			throw new BuilderException('Property [playbackRate] is required.');
		}
		$instance->playbackRate = $this->playbackRate;
		return $instance;
	}
353786
public function video($video = null, array $options = array()) {
        if (!func_num_args()) {
            // provide fluent interface
            return $this;
        }
        if (!$video) {
            throw new InvalidArgumentException(
                __METHOD__ . ' expects parameter 1 to be Garp_Db_Table_Row'
            );
        }
        return $this->render($video, $options);
    }
437915
public function setAudioEncoding($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\TextToSpeech\V1\AudioEncoding::class);
        $this->audio_encoding = $var;

        return $this;
    }
193586
public function setDescriptionurl($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->descriptionurl !== $v) {
            $this->descriptionurl = $v;
            $this->modifiedColumns[MediaTableMap::COL_DESCRIPTIONURL] = true;
        }

        return $this;
    }
741946
public function storePermanentVideo (Video $video)
    {
        if ($video->getTitle() === null || $video->getDescription() === null) {
            throw new InvalidArgumentException("permanent videos must have a title and description");
        }

        return $this->storeVideo(true, $video);
    }
1025601
public function source($source)
    {
        $oldSource = $this->source;

        $this->source = $source;
        $parsedURL = parse_url($source);

        // 1 thing, auto-detect based on ID
        if (count($parsedURL) === 1) {
            if (substr(strtoupper($parsedURL['path']), 0, 2) == 'PL') {
                return $this->playlist($source);
            } else {
                return $this->video($source);
            }
        }

        // Else, try to detect in turn.
        try {
            return $this->video($source);
        } catch (AudioPlayerException $e) {
        } // do nothing.  Might be playlist.

        try {
            return $this->playlist($source);
        } catch (AudioPlayerException $e) {
            $this->source = $oldSource;
            throw new AudioPlayerException('Could not detect source');
        }
    }
1333449
public function setReplaycount($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->replaycount !== $v) {
            $this->replaycount = $v;
            $this->modifiedColumns[MxmapTableMap::COL_REPLAYCOUNT] = true;
        }

        return $this;
    }
1365679
public function isVimeo($video) {
        $playerurl = (is_string($video) ? $video :
            (isset($video['player']) ? $video['player'] : $video));
        return preg_match('~player\.vimeo\.com~i', $playerurl);
    }
1264800
public function setFrameRate($frameRate)
	{
		if ( ! is_numeric($frameRate) || $frameRate < 0)
		{
			throw new \InvalidArgumentException('Wrong the frame rate value.');
		}
		
		$this->videoFrameRate = $frameRate;
		
		return $this;
	}