Get information about video and images from link
Media Embed class allows you to retrieve information about media like Video or Images by simply using link or embed code from media providers like Youtube, Myspace, etc.
It can retrieve embeding codes, title, sizes and thumbnails from more than 20 popular media providers
Contents
Download
Example codes
<?php //include class include("media_embed.php"); //provide media link $em = new media_embed('http://youtu.be/xs-rgXUu448'); //check if found anything useful $site = $em->get_site(); if($site != "") { echo "<p>Link to media:</p>"; echo "<p><a href='".$em->get_url()."'>"; $size = $em->get_size(); echo "<img src='".$em->get_thumb("small")."'/>"; echo "</a></p>"; echo "<p>Or embed it:</p>"; echo "<p>"; $code = $em->get_iframe(); if($code == "") { $code = $em->get_embed(); } echo $code; echo "</p>"; } else { echo "<h3>Cannot get info from this source</h3>"; } ?>
Examples in action
Example scripts provided with package in action:
Method list
- Constructor
- Get media thumbnail
- Get iframe code
- Get embed code
- Get URL
- Get media id
- Get website URL
- Get dimensions of video
- Get Title of media
Constructor
| Method name | new media_embed($data) |
| Description | Create instance of class from provided information about media content |
| Input parameters | string $data - information about media, for example link to media website, or it's embed code |
| Example input |
new media_embed("http://www.youtube.com/watch?v=c8uU3C1NAoo&feature=fvst");
|
Get media thumbnail
| Method name | get_thumb($size = "small") |
| Description | Returns URL to Media thumbnail |
| Input parameters | string $size - size of thumbnail, supports 3 values: small, medium, large. (default: small) |
Get iframe code
| Method name | get_iframe($w = -1, $h = -1) |
| Description | Returns Iframe code for media embedding |
| Input parameters | int $w - width of embeded video. (default: -1, means default width is used) int $h - height of embeded video. (default: -1, means default height is used) |
| Example input | get_iframe(320, 200) |
| Example output | <iframe width="320" height="200" src="http://www.youtube.com/embed/xxxxxxxxxx" frameborder="0" allowfullscreen></iframe> |
Get embed code
| Method name | get_embed($w = -1, $h = -1) |
| Description | Returns object/embed code for media embedding |
| Input parameters | int $w - width of embeded video. (default: -1, means default width is used) int $h - height of embeded video. (default: -1, means default height is used) |
| Example input | get_embed(320, 200) |
| Example output | <object width="320" height="200" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="http://www.youtube.com/v/xxxxxxxxxx"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/xxxxxxxxxx" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="200"></embed></object> |
Get URL
| Method name | get_url() |
| Description | Returns URL of media's webpage |
| Example output | http://www.youtube.com/watch?v=xxxxxxxxxx |
Get media id
| Method name | get_id() |
| Description | Returns Identification code of media |
| Example output | xxxxxxxxxx |
Get website URL
| Method name | get_site() |
| Description | Returns URL of website where media was embeded |
| Example output | http://www.youtube.com |
Get dimensions of video
| Method name | get_size() |
| Description | Returns array with dimensions of video, where "w" represents width and "h" - height |
| Example output | Array ( "w" => 320 "h" => 240 ) |
Get Title of media
| Method name | get_title() |
| Description | Returns title of provided media |
| Example output | Awesome Video |
Supported websites
Here is a list of all supported media providers
| Website | Data supported as input | Supported methods |
| 5min | Video URL, Embed code | All |
| Blip.tv | Video URL | All |
| Clickthrough | Video URL, Embed code | All |
| Dailymotion | Video URL, Embed code, Iframe code | All |
| Dotsub | Video URL, Embed code | All |
| Video URL, Embed code | All | |
| Flickr | Image URL | Doesn't support iframe and embed methods. Returns size of medium size image. |
| Funny or Die | Video URL | All |
| Hulu | Video URL | All |
| Metacafe | Video URL, Embed code | All |
| Myspace | Video URL, Embed code, Hulu code | All |
| Qik.com | Video URL | All |
| Revision3 | Video URL | All |
| Revver | Video URL, Embed code, Flash code, QuickTime code, Javascript code, Image code | All exept get_iframe() (causes download dialog) |
| Screenr | Video URL | All except get_embed() |
| Slideshare | Video URL | All except get_embed() |
| Twitpic | Image URL | Supports only get_thumb method for all 3 sizes |
| Viddler | Video URL | All |
| Videojug | Video URL | All |
| Vimeo | Video URL, Embed code, Iframe code | All |
| Yfrog | Image URL, Video URL, | Image doesn't support iframe and embed methods and returns size of large size image. Video supports all methods |
| Youtube | Video URL, Short URL, Embed code, Iframe code | All |
Latest changes
None for now
Rate us
Try it out and Rate on PHPclasses.org
Support
PHP classes support forum or comments below
You may also be interested in:
Powered by BlogAlike.com










