videoentry.php

来自「Bug tracker, and reporter.」· PHP 代码 · 共 727 行 · 第 1/2 页

PHP
727
字号
    /**     * Returns the comments relating to the video.     *     * @return Zend_Gdata_Extension_Comments  The comments relating to the video     */    public function getComments()    {        return $this->_comments;    }    /**     * Sets the array of embedded feeds related to the video     *     * @param array $feedLink The array of embedded feeds relating to the video     * @return Zend_Gdata_YouTube_VideoEntry Provides a fluent interface     */    public function setFeedLink($feedLink = null)    {        $this->_feedLink = $feedLink;        return $this;    }    /**     * Get the feed link property for this entry.     *     * @see setFeedLink     * @param string $rel (optional) The rel value of the link to be found.     *          If null, the array of links is returned.     * @return mixed If $rel is specified, a Zend_Gdata_Extension_FeedLink     *          object corresponding to the requested rel value is returned     *          if found, or null if the requested value is not found. If     *          $rel is null or not specified, an array of all available     *          feed links for this entry is returned, or null if no feed     *          links are set.     */    public function getFeedLink($rel = null)    {        if ($rel == null) {            return $this->_feedLink;        } else {            foreach ($this->_feedLink as $feedLink) {                if ($feedLink->rel == $rel) {                    return $feedLink;                }            }            return null;        }    }    /**     * Returns the link element relating to video responses.     *     * @return Zend_Gdata_App_Extension_Link     */    public function getVideoResponsesLink()    {        return $this->getLink(Zend_Gdata_YouTube::VIDEO_RESPONSES_REL);    }    /**     * Returns the link element relating to video ratings.     *     * @return Zend_Gdata_App_Extension_Link     */    public function getVideoRatingsLink()    {        return $this->getLink(Zend_Gdata_YouTube::VIDEO_RATINGS_REL);    }    /**     * Returns the link element relating to video complaints.     *     * @return Zend_Gdata_App_Extension_Link     */    public function getVideoComplaintsLink()    {        return $this->getLink(Zend_Gdata_YouTube::VIDEO_COMPLAINTS_REL);    }    /**     * Gets the YouTube video ID based upon the atom:id value     *     * @return string The video ID     */    public function getVideoId()    {        $fullId = $this->getId()->getText();        $position = strrpos($fullId, '/');        if ($position === false) {            require_once 'Zend/Gdata/App/Exception.php';            throw new Zend_Gdata_App_Exception('Slash not found in atom:id');        } else {            return substr($fullId, strrpos($fullId,'/') + 1);        }    }    /**     * Gets the georss:where element     *     * @return Zend_Gdata_Geo_Extension_GeoRssWhere     */    public function getWhere()    {        return $this->_where;    }    /**     * Sets the georss:where element     *     * @param Zend_Gdata_Geo_Extension_GeoRssWhere $value The georss:where class value     * @return Zend_Gdata_YouTube_VideoEntry Provides a fluent interface     */    public function setWhere($value)    {        $this->_where = $value;        return $this;    }    /**     * Gets the title of the video as a string.  null is returned     * if the video title is not available.     *     * @return string The title of the video     */    public function getVideoTitle()    {        if (($mediaGroup = $this->getMediaGroup()) != null &&             $mediaGroup->getTitle() != null) {            return $mediaGroup->getTitle()->getText();        } else {            return null;        }    }    /**     * Gets the description  of the video as a string.  null is returned     * if the video description is not available.     *     * @return string The description of the video     */    public function getVideoDescription()    {        if (($mediaGroup = $this->getMediaGroup()) != null &&             $mediaGroup->getDescription() != null) {            return $mediaGroup->getDescription()->getText();        } else {            return null;        }    }    /**     * Gets the URL of the YouTube video watch page.  null is returned     * if the video watch page URL is not available.     *     * @return string The URL of the YouTube video watch page     */    public function getVideoWatchPageUrl()    {        if (($mediaGroup = $this->getMediaGroup()) != null &&             $mediaGroup->getPlayer() != null &&             array_key_exists(0, $mediaGroup->getPlayer())) {            $players = $mediaGroup->getPlayer();            return $players[0]->getUrl();        } else {            return null;        }    }    /**     * Gets an array of the thumbnails representing the video.     * Each thumbnail is an element of the array, and is an     * array of the thumbnail properties - time, height, width,     * and url.  For convient usage inside a foreach loop, an     * empty array is returned if there are no thumbnails.     *     * @return string The URL of the YouTube video watch page     */    public function getVideoThumbnails()    {        if (($mediaGroup = $this->getMediaGroup()) != null &&             $mediaGroup->getThumbnail() != null) {            $thumbnailArray = array();            foreach ($mediaGroup->getThumbnail() as $thumbnailObj) {                $thumbnail = array();                $thumbnail['time'] = $thumbnailObj->time;                $thumbnail['height'] = $thumbnailObj->height;                $thumbnail['width'] = $thumbnailObj->width;                $thumbnail['url'] = $thumbnailObj->url;                $thumbnailArray[] = $thumbnail;            }            return $thumbnailArray;        } else {            return array();        }    }    /**     * Gets the URL of the flash player SWF.  null is returned if the     * duration value is not available.     *     * @return string The URL of the flash player SWF     */    public function getFlashPlayerUrl()    {        if ($this->getMediaGroup() != null) {            foreach ($this->getMediaGroup()->getContent() as $content) {                if ($content->getType() === 'application/x-shockwave-flash') {                    return $content->getUrl();                }            }        }        return null;    }    /**     * Gets the duration of the video, in seconds.  null is returned     * if the duration value is not available.     *     * @return string The duration of the video, in seconds.     */    public function getVideoDuration()    {        if ($this->getMediaGroup() != null &&            $this->getMediaGroup()->getDuration() != null) {            return $this->getMediaGroup()->getDuration()->getSeconds();        } else {            return null;        }    }    /**     * Gets an array of the tags assigned to this video.  For convient     * usage inside a foreach loop, an empty array is returned when there     * are no tags assigned.     *     * @return array An array of the tags assigned to this video     */    public function getVideoTags()    {        if ($this->getMediaGroup() != null &&            $this->getMediaGroup()->getKeywords() != null) {            $keywords = $this->getMediaGroup()->getKeywords();            $keywordsString = (string) $keywords;            if (strlen(trim($keywordsString)) > 0) {                return split('(, *)|,', $keywordsString);            }        }        return array();    }    /**     * Gets the number of views for this video.  null is returned if the     * number of views is not available.     *     * @return string The number of views for this video     */    public function getVideoViewCount()    {        if ($this->getStatistics() != null) {            return $this->getStatistics()->getViewCount();        } else {            return null;        }    }    /**     * Gets the location specified for this video, if available.  The location     * is returned as an array containing the keys 'longitude' and 'latitude'.     * null is returned if the location is not available.     *     * @return array The location specified for this video     */    public function getVideoGeoLocation()    {        if ($this->getWhere() != null &&            $this->getWhere()->getPoint() != null &&            ($position = $this->getWhere()->getPoint()->getPos()) != null) {            $positionString = $position->__toString();            if (strlen(trim($positionString)) > 0) {                $positionArray = explode(' ', trim($positionString));                if (count($positionArray) == 2) {                    $returnArray = array();                    $returnArray['latitude'] = $positionArray[0];                    $returnArray['longitude'] = $positionArray[1];                    return $returnArray;                }            }        }        return null;    }    /**     * Gets the rating information for this video, if available.  The rating     * is returned as an array containing the keys 'average' and 'numRaters'.     * null is returned if the rating information is not available.     *     * @return array The rating information for this video     */    public function getVideoRatingInfo()    {        if ($this->getRating() != null) {            $returnArray = array();            $returnArray['average'] = $this->getRating()->getAverage();            $returnArray['numRaters'] = $this->getRating()->getNumRaters();            return $returnArray;        } else {            return null;        }    }    /**     * Gets the category of this video, if available.  The category is returned     * as a string. Valid categories are found at:     * http://gdata.youtube.com/schemas/2007/categories.cat     * If the category is not set, null is returned.     *     * @return string The category of this video     */    public function getVideoCategory()    {        if ($this->getMediaGroup() != null &&            ($categoryArray = $this->getMediaGroup()->getCategory()) != null) {            foreach ($categoryArray as $category) {                if ($category->getScheme() == 'http://gdata.youtube.com/schemas/2007/categories.cat') {                    return $category->getText();                }            }        }        return null;    }    /**     * Get the current publishing state of the video.      *     * @return Zend_Gdata_YouTube_Extension_State The publishing state of this video     */    public function getVideoState()    {        $control = $this->getControl();        if ($control != null &&             $control->getDraft() != null &&             $control->getDraft()->getText() == 'yes') {            return $control->getState();        }        return null;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?