copadia/php-video-url-parser
最新稳定版本:v1.0.3
Composer 安装命令:
composer require copadia/php-video-url-parser
包简介
A Simple and efficient PHP Video URL Parser that gives you thumbnails and embed codes for various services as Youtube, Vimeo, DailyMotion and Facebook
README 文档
README
PHP Video URL Parser is a parser that detects a given video url and returns an object containing information like the video's embed code, title, description, thumbnail and other information that the service's API may give.
Installation
Install the latest version with
$ composer require copadia/php-video-url-parser
Requirements
- PHP 5.3
- cURL (Or at least file_get_contents() enabled if you want to use it with Vimeo, otherwise it's not required)
Basic Usage
<?php use RicardoFiorani\Matcher\VideoServiceMatcher; require __DIR__ . '/vendor/autoload.php'; $vsm = new VideoServiceMatcher(); //Detects which service the url belongs to and returns the service's implementation //of RicardoFiorani\Adapter\VideoAdapterInterface $video = $vsm->parse('https://www.youtube.com/watch?v=PkOcm_XaWrw'); //Checks if service provides embeddable videos (most services does) if ($video->isEmbeddable()) { //Will echo the embed html element with the size 200x200 echo $video->getEmbedCode(200, 200); //Returns the embed html element with the size 1920x1080 and autoplay enabled echo $video->getEmbedCode(1920, 1080, true); //Returns the embed html element with the size 1920x1080, autoplay enabled and force the URL schema to be https. echo $video->getEmbedCode(1920, 1080, true, true); } //If you don't want to check if service provides embeddable videos you can try/catch try { echo $video->getEmbedUrl(); } catch (\RicardoFiorani\Exception\NotEmbeddableException $e) { die(sprintf("The URL %s service does not provide embeddable videos.", $video->getRawUrl())); } //Gets URL of the smallest thumbnail size available echo $video->getSmallThumbnail(); //Gets URL of the largest thumbnail size available //Note some services (such as Youtube) does not provide the largest thumbnail for some low quality videos (like the one used in this example) echo $video->getLargestThumbnail();
Currently Suported Services
- Youtube
- Vimeo
- Dailymotion
- Facebook Videos
Currently Supported PHP Versions
- PHP 5.3
- PHP 5.4
- PHP 5.5
- PHP 5.6
- PHP 7.0
- PHP 7.1
统计信息
- 总下载量: 14.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-12