15

I have made an RSS reader app in Xcode, which gets it's information from a YouTube channel. How can I get the thumbails from the videos?

I am able to use this link: http://gdata.youtube.com/feeds/mobile/users/HaatFilms/uploads?alt=rss

To get the uploads text, but what would I use to get the thumbnail for each specific video?

2
  • But how can I find the Video ID of a Video and then display it in a tableView? Commented Sep 15, 2013 at 12:29
  • Using that RSS feed? There's a proper API for youtube. Commented Sep 15, 2013 at 12:36

2 Answers 2

18

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"]];
Sign up to request clarification or add additional context in comments.

Comments

5

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"]];

2 Comments

Sorry, I have been busy, When I Tried it.. It didn't work. Am I supposed to add something else other than the stated code above?
yeah you need to add afnetworking to load images asynchronous in you app. What error you are getting

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.