ivopetkov / video-embed
Video embed library
Fund package maintenance!
ivopetkov
www.paypal.me/ivopetkovcom
Installs: 8 651
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 4
Open Issues: 2
Requires
- php: 7.1.*|7.2.*|7.3.*|7.4.*|8.0.*|8.1.*|8.2.*|8.3.*
README
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.
Download and install
- 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.
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] => <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
Documentation
Classes
IvoPetkov\VideoEmbed
Constants
const string VERSION
Properties
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
Methods
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
License
Video Embed is open-sourced software. It's free to use under the MIT license. See the license file for more information.
Author
This library is created by Ivo Petkov. Feel free to contact me at @IvoPetkovCom or ivopetkov.com.