0

trying to assign youtube thumbnail I receive from youtube api to a datatype or something of some sort so it can be passed through my system and appear in a image box on my website

have tried using system.drawing.bitmap and system.drawing.image and get error:

'cannot implicitly convert type'

 foreach (var playlistItem in playlistItemsListResponse.Items)
                {
                // Print information about each video.

                //Console.WriteLine("{0} ({1})",playlistItem.Snippet.Thumbnails, playlistItem.Snippet.Title, playlistItem.Snippet.ResourceId.VideoId);
                playlistItem.Snippet.ResourceId.VideoId = vidDetails.vidId;
                playlistItem.Snippet.Title= vidDetails.vidTitle;
                playlistItem.Snippet.Thumbnails = vidDetails.vidThumb;



                }

video details:

   public string vidId { get; set; }
   public string vidTitle { get; set; }
   public string vidDesc { get; set; }
   public string vidTags { get; set; }
   public System.Drawing.Bitmap vidThumb { get; set; }  

display: protected void Page_Load(object sender, EventArgs e) {

    Video_details vidDetails = new Video_details();

uploaded_videos uploadedVids = new uploaded_videos();
    new uploaded_videos().Run(vidDetails).Wait();


    vidDetails.vidThumb = imgVid1....



}
}
Kara
  • 6,115
  • 16
  • 50
  • 57
shove195
  • 7
  • 4

2 Answers2

0

Try using PictureBox.Load("https://i.ytimg.com/vi/abcdefghijk/default.jpg") from the PictureBox.Load method in C#.

You can also use the method provided in this SO thread:

var request = WebRequest.Create("http://www.gravatar.com/avatar/6810d91caff032b202c50701dd3af745?d=identicon&r=PG");

using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
{
    pictureBox1.Image = Bitmap.FromStream(stream);
}
Community
  • 1
  • 1
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
0

snippet.thumbnails property is an object that identifies the thumbnail images available for that resource.A thumbnail resource contains a series of objects. The name of each object (default, medium, high, etc.) refers to the thumbnail image size.

        item.Snippet.Thumbnails.Default__.Url

will give you the address of default thumbnail image by accessing which you can use Image and assign it to the local variables and vice versa.