Search code examples
vimeovideo-thumbnails

Get Thumbnail in Vimeo


Is there any way to get the thumbnail from server side call?

The only method that I researched is:

$.getJSON('http://www.vimeo.com/api/v2/video/' + vimeoVideoId + '.json?callback=?', { format: "json" }, function (data) {
        $(".thumbnail").attr('src', data[0].thumbnail_medium);
    });

Is there a way to make the same call from code behind? or is there a single URL call like in youtube

img.youtube.com/vi/{0}/0.jpg

Solution

    1. List item

    I found a way to do this from code behind:

     public static string GetVimeoPreviewImage(string videoId)
     {
         var imageUrl = string.Empty;
         try
         {
             var doc = new XmlDocument();
             doc.Load("http://vimeo.com/api/v2/video/" + videoId + ".xml");
             var root = doc.DocumentElement;
             if (root != null)
             {
                 var selectSingleNode = root.FirstChild.SelectSingleNode("thumbnail_medium");
                 if (selectSingleNode != null)
                 {
                     var vimeoThumb = selectSingleNode.ChildNodes[0].Value;
                     imageUrl = vimeoThumb;
                     return imageUrl;
                 }
             }
         }
         catch (Exception ex)
         {
             var message = string.Format("{0} Exception: {1}", typeof(VideoHelper).FullName, ex.Message);
             Log.Error(message, typeof(VideoHelper));
         }
         return imageUrl;
     }