Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I saw some other similar threads but they were all for YouTube videos. I was wondering if the same could be done for videos hosted on other servers like blip. Here is an example of a blip video: http://blip.tv/file/4778330

This is how I currently have things set up:

I have a custom post type for Videos with a meta box for the src (video_src) from the embed code so all I have to do is enter the src and it gets displayed from my single-videos.php template like this:

<embed src="<?=$video_src?>" type="application/x-shockwave-flash" width="400" height="200" allowscriptaccess="always" allowfullscreen="true" />

It would be awesome if somehow a frame of the video became the featured thumbnail of its post. Any idea on how something like this could be done?

share|improve this question

4 Answers 4

up vote 3 down vote accepted

You can use the Blip TV API:

http://wiki.blip.tv/index.php/Blip.tv_API

Look for "How do I find the thumbnail for an item?" Examples of the API can be found in the wiki e.g. the PHP Example:

include_once("blipPHP.php");
$blipPHP = new blipPHP("username", "password");
$respond = $blipPHP->info(4794325);

returns a LONG array. Inside this you find:

[3] => SimpleXMLElement Object
                                    (
                                        [@attributes] => Array
                                            (
                                                [rel] => alternate
                                                [type] => application/rss+xml
                                                [href] => http://blip.tv/rss/4812438
                                            )

                                    )

Now make a call to get http://blip.tv/rss/4812438 (you can check this one in your browser)

And you can parse the returned content for the thumnail as in the xpath expression given as you find:

<media:thumbnail url="http://a.images.blip.tv/Oldjewstellingjokes-AdrianeBergPastorFuzz165.jpg"/>

Now... maybe you have some questions:

1 how do i program something to get a url (URI) in a string?

WordPress provides a default method for that: wp_remote_get : READ: http://codex.wordpress.org/HTTP_API (see also http://core.trac.wordpress.org/ticket/4779)

2 Ok... now I have some website in a string what do i do with it?

Whatever you can think of, if it is stuff that is not "XML" related you will probably use smart regex to parse the content out of the string. (see php regex)

But.... to make stuff more readable for yourself, read the string in a DOM and then use XPath to quickly scan for the content. (see google:xpath or php.net: xpath)

$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->strictErrorChecking = false;
if (!$dom->loadHTML($data)) 
{
   foreach (libxml_get_errors() as $error) 
   {
     //     handle errors here
    }
    libxml_clear_errors();      
} 
else
{
   $xpath = new DOMXPath($dom);
   $elements = $xpath->query('/rss/channel/item/media:thumbnail/@url');

TADA! the thumbnail we found:

share|improve this answer
    
@edelwater It says I need a username/password to access. –  J82 Feb 21 '11 at 8:46
    
Yes but the box that appears gives you the username and password(read the message). –  t31os Feb 21 '11 at 12:24
    
Ah, I apologize for that. I should have actually read the message. I've read over the relevant section and I'm not sure how to find the url. It says the thumbnail can be found at /rss/channel/item/media:thumbnail/@url so I tried this but it didn't work: http://blip.tv/rss/channel/item/media:thumbnail/@http://blip.tv/file/4778330 Any ideas? –  J82 Feb 21 '11 at 18:52
    
but uhm.... are you using the API? –  edelwater Feb 21 '11 at 23:32
    
That is an XPath expression in other words: GET the rss feed from the item (via code NOT your browser), then read the DOM and output the thumbnail via e.g. Xpath as in the exmaple. –  edelwater Feb 21 '11 at 23:53

Bottom line is that there is probably no generic way to do it, because every service has its own API and methods and such.

share|improve this answer
    
I feel a plugin coming............ grin! –  edelwater Feb 22 '11 at 17:05

It would seem that the thumbnail blip creates for each video isn't like youtube, where you can use the videoid to figure it out.

Here are two of your videos/thumbs from blip:

http://blip.tv/file/4778330 http://a.images.blip.tv/Thebaytheseries-WEBISODE14TheBayChapter4Part2721-711.jpg

http://blip.tv/file/4690791 http://a.images.blip.tv/Thebaytheseries-THEBAYTheSeriesSOMETHINGSADMusicVideoByTedKorsmo777-169.jpg

So it doesn't look possible.

share|improve this answer
    
Actually, I made a mistake in my post. It doesn't actually have to be the first frame. It can be any frame of the video. So, would it still be impossible? –  J82 Feb 21 '11 at 8:48

If you want a more generic method, you could try oEmbed, which supports a thumbnail_url property for videos. Many sites have oEmbed support built in, but oohEmbed or Embedly offer many more services through the same API.

For example, the oohEmbed request for your video returns the following information:

{
    "type": "video",
    "version": "1.0",
    "title": "WEBISODE 14 - The Bay - Chapter 4 - Part 2",
    "author_name": "TheBaytheSeries",
    "author_url": "http://TheBaytheSeries.blip.tv",
    "provider_name": "blip.tv",
    "provider_url": "http://blip.tv",
    "width": 720,
    "height": 436,
    "html": "<embed src=\"http://blip.tv/play/AYKk4RQC\" type=\"application/x-shockwave-flash\" width=\"720\" height=\"436\" allowscriptaccess=\"always\" allowfullscreen=\"true\"></embed>",
    "thumbnail_url": "http://a.images.blip.tv/Thebaytheseries-WEBISODE14TheBayChapter4Part2721.png",
    "thumbnail_width": 720,
    "thumbnail_height": 436 
}
share|improve this answer
    
interesting! found also this: wordpress.org/extend/plugins/embedly (blog.embed.ly/embedly-wordpress-plugin) –  edelwater Feb 22 '11 at 17:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.