27
Nov
2008
0

Retrieve video details from YouTube using c#

Below is a code to retrieve a YouTube video’s details using the Google API.
You may first download and install the Google Data Api, and apply for a developer ID.

YouTubeService service = new YouTubeService("example app", "ytapi-Phoceis-Youtubeforkids-jktgue07-0", "AI39si6XU6CYi6Qo52i7qD7OLEZ7JBebKPGgHAzmN34UF23HRBYtcT7B_eWvoiTCDCaO7ePAaCFs6aCzeNNR535shbeH63IXNQ");
 
String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/" + ID_of_your_video;
YouTubeEntry videoEntry = (YouTubeEntry)service.Get(videoEntryUrl);
 
if (videoEntry != null)
{
            tex_titre.Text = videoEntry.Title.Text;
            if (videoEntry.Media.Thumbnails.Count > 0)
            {
                // here we populate an aspxcombobox (a component from DevExpress) with the collection of thumbnails of the video, but you may also use classic radiobutton
                com_images.DataSource = videoEntry.Media.Thumbnails;
                com_images.ImageUrlField = "Url";
                com_images.TextField = "Url";
                com_images.DataBind();
                com_images.SelectedIndex = 0;
            }
            tex_kw.Text = videoEntry.Media.Keywords.Value;
            lab_length.Text = videoEntry.Duration.Seconds.ToString();
}
Ecrit par julien dans : .NET | Tags : , , , ,

Propulsé par WordPress | Thème Aeros | TheBuckmaker.com WordPress Themes | Traduction WordPress tuto