Simple library that returns embed information for a given video url.
Supported video services: Dailymotion, Facebook, Flickr, Hulu, Kickstarter, The New York Times, Ted, Vimeo, Vine, YouTube.
- Install via Composer
composer require ivopetkov/video-embed
- Download the zip file
Download the latest release from our GitHub page, unzip and include the autoload.php
file.
$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] => <iframe width="480" height="270" src="https://www.youtube.com/embed/Pwe-pA6TaZk?feature=oembed" frameborder="0" allowfullscreen></iframe>
// [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
const string VERSION
public string $url
The video url
public string $html
The video html code
public string|int $width
The video width
public string|int $height
The video height
public int $duration
The video duration
public string $title
The video title
public string $description
The video description
public array $thumbnail
An array containing an url and sizes for the video thumbnail image
public array $author
An array containing the name and the url of the author
public array $provider
An array containing the name and the url of the provider
public string $rawResponse
The raw response from the provider embed endpoint
public __construct ( [ string $url ] )
Creates a new VideoEmbed object and load it if an url is specified
Parameters
$url
The video url
Returns
No value is returned.
public void load ( string $url )
Loads the data for the url specified
Parameters
$url
The video url
Returns
No value is returned
public void setSize ( string|int $width , string|int $height )
Sets new width and height in the video html code
Parameters
$width
Thew new width
$height
Thew new height
Returns
No value is returned
Video Embed is open-sourced software. It's free to use under the MIT license. See the license file for more information.
This library is created by Ivo Petkov. Feel free to contact me at @IvoPetkovCom or ivopetkov.com.