How to get Youtube Thumbnails

This question already has an answer here:

  • How do I get a YouTube video thumbnail from the YouTube API? 29 answers

  • Using the listed RSS feed:

    You'll see links that include:

    LKk6SvGmJj4
    

    Previous episode: http://youtu.be/ LKk6SvGmJj4 http://gdata.youtube.com/feeds/mobile/videos/ LKk6SvGmJj4

    That's the youtube ID.

    Take that ID and use it with a straight image tag.

    http://img.youtube.com/vi/LKk6SvGmJj4/0.jpg
    http://img.youtube.com/vi/LKk6SvGmJj4/1.jpg
    

    Use those images to populate your tables. Personally, I use Afnetworking's UIImageView category.

    https://github.com/AFNetworking/AFNetworking

     UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
     [imageView setImageWithURL:[NSURL URLWithString:@"http://img.youtube.com/vi/LKk6SvGmJj4/1.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]];
    

    I have used UIImageView+AFNetworking category to load image to an UIImageView . UIImageView+AFNetworking

    NSString * youtubeID = @"TJkmc8-eyvE";
    NSURL *youtubeURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://img.youtube.com/vi/%@/0.jpg",youtubeId];
    
    [imageView setImageWithURL:youtubeURL] placeholderImage:[UIImage imageNamed:@"placeHolderImage"]];
    
    链接地址: http://www.djcxy.com/p/28898.html

    上一篇: 使用PHP进行数据迁移

    下一篇: 如何获得Youtube缩略图