When hosting Google Video's on your site it can be handy to pull back the thumbnail for the video image. Currently there is no API for doing this so I wrote a method to do it for me.
First I retrieve the RSS feed for the video. Then I pull out the thumbnail path from that feed.
private static string GetGoogleThumnailPath(string contentID)
{
string path = null;
// Fetch the RSS for the video
WebRequest req = HttpWebRequest.Create("http://video.google.com/videofeed?docid=" + contentID);
req.Method = "GET";
WebResponse response = req.GetResponse();
XmlTextReader stream = new XmlTextReader(response.GetResponseStream());
XPathDocument doc = new XPathDocument(stream);
XPathNavigator nav = doc.CreateNavigator();
XmlNamespaceManager manager = new XmlNamespaceManager(nav.NameTable);
manager.AddNamespace("media", "http://search.yahoo.com/mrss/");
XPathNodeIterator iterator = nav.Select("/rss/channel/item/media:group/media:thumbnail/@url", manager);
while (iterator.MoveNext())
{
path = iterator.Current.Value;
}
return path;
}
We used this code on the
Pets Best Community site. By the way if you are interested in
Pet Insurance you can use my Promo Code: CISAKSON5 for a 5% discount. If you do not see the box to enter it on the Get a Quote page then it probably has automatically been applied through one of my links.