Video Embed
Simple library that returns embed information for a given video url., (*1)
Supported video services: Dailymotion, Facebook, Flickr, Hulu, Kickstarter, The New York Times, Ted, Vimeo, Vine, YouTube., (*2)
, (*3)
Download and install
composer require ivopetkov/video-embed
Download the latest release from our GitHub page, unzip and include the autoload.php
file., (*4)
Usage
$videoEmbed = new IvoPetkov\VideoEmbed('https://www.youtube.com/watch?v=Pwe-pA6TaZk');
// IvoPetkov\VideoEmbed Object
// (
// [url] => https://www.youtube.com/watch?v=Pwe-pA6TaZk
// [html] =>
// [width] => 480
// [height] => 270
// [duration] =>
// [title] => Where the Hell is Matt? 2012
// [description] =>
// [thumbnail] => Array
// (
// [url] => https://i.ytimg.com/vi/Pwe-pA6TaZk/hqdefault.jpg
// [width] => 480
// [height] => 360
// )
// [author] => Array
// (
// [name] => Matt Harding
// [url] => https://www.youtube.com/user/mattharding2718
// )
// [provider] => Array
// (
// [name] => YouTube
// [url] => https://www.youtube.com/
// )
// [rawResponse] => {"html": "\u003ciframe width=\"480\" height=\"270\" ...
// )
$videoEmbed->setSize(800, 600); // will set a new width and height in the video html code
Documentation
Classes
IvoPetkov\VideoEmbed
Constants
const string VERSION
, (*5)
Properties
public string $url
, (*6)
The video url, (*7)
public string $html
, (*8)
The video html code, (*9)
public string|int $width
, (*10)
The video width, (*11)
public string|int $height
, (*12)
The video height, (*13)
public int $duration
, (*14)
The video duration, (*15)
public string $title
, (*16)
The video title, (*17)
public string $description
, (*18)
The video description, (*19)
public array $thumbnail
, (*20)
An array containing an url and sizes for the video thumbnail image, (*21)
public array $author
, (*22)
An array containing the name and the url of the author, (*23)
public array $provider
, (*24)
An array containing the name and the url of the provider, (*25)
public string $rawResponse
, (*26)
The raw response from the provider embed endpoint, (*27)
Methods
public __construct ( [ string $url ] )
Creates a new VideoEmbed object and load it if an url is specified, (*28)
Parameters, (*29)
$url
, (*30)
The video url, (*31)
Returns, (*32)
No value is returned., (*33)
public void load ( string $url )
Loads the data for the url specified, (*34)
Parameters, (*35)
$url
, (*36)
The video url, (*37)
Returns, (*38)
No value is returned, (*39)
public void setSize ( string|int $width , string|int $height )
Sets new width and height in the video html code, (*40)
Parameters, (*41)
$width
, (*42)
Thew new width, (*43)
$height
, (*44)
Thew new height, (*45)
Returns, (*46)
No value is returned, (*47)
License
Video Embed is open-sourced software. It's free to use under the MIT license. See the license file for more information., (*48)
Author
This library is created by Ivo Petkov. Feel free to contact me at @IvoPetkovCom or ivopetkov.com., (*49)