Stickerbox
Stickerbox

Reputation: 141

YouTube in UITableView

Ok so I'm finding this insanely difficult to find for something that is done a lot. I'm struggling to find a way of putting the newest YouTube videos from a user into a UITableView.

I've tried this but it's out of date and I gets heaps of errors: http://code.google.com/p/gdata-objectivec-client/downloads/detail?name=gdata-objectivec-client-1.11.0.zip

Aside from using a UIWebView, are there any good tutorials, that work, on putting YouTube videos in a UITableView?

Upvotes: 1

Views: 652

Answers (2)

TonyMkenu
TonyMkenu

Reputation: 7677

Let's take an example.. for Nethfel user; click on his playlist; in the link bar you will see "http://www.youtube.com/watch?v=4nx7g60Ldig&list=UUANsW00CkQnNnnUyuC1cygw"

now .. we take the playlist "number" UUANsW00CkQnNnnUyuC1cygw and.. we will make an JSON request..max 50 results

http://gdata.youtube.com/feeds/api/playlists/UUANsW00CkQnNnnUyuC1cygw?v=2&alt=jsonc&max-results=50

You can replace JSON with JSONC - you will se minor changes in your results; This will be your request at the beginning of your app

Now we must "interpret/translate" the next result:

{
apiVersion: "2.1",
data: {
id: "UUANsW00CkQnNnnUyuC1cygw",
author: "Nethfel",
title: "Uploaded videos",
description: "",
thumbnail: {
sqDefault: "http://i.ytimg.com/vi/4nx7g60Ldig/default.jpg",
hqDefault: "http://i.ytimg.com/vi/4nx7g60Ldig/hqdefault.jpg"
},
content: {
5: "http://www.youtube.com/p/UUANsW00CkQnNnnUyuC1cygw"
},
totalItems: 17,
startIndex: 1,
itemsPerPage: 50,
items: [
{
id: "UUGCa8nZNU7uOfDF3zV9AxkJtJSuX5gHGI",
position: 1,
author: "Nethfel",
video: {
id: "4nx7g60Ldig",
uploaded: "2011-11-02T12:32:03.000Z",
updated: "2013-01-07T18:26:41.000Z",
uploader: "nethfel",
category: "Howto",
title: "iOS Passing Data Between View Controllers Technique 1",
description: "This video discusses one of the most basic techniques for passing data between view controllers in an iOS application. This technique uses storing a local iVar in one class and passing it to the second class about to be displayed on the screen. Although this is a very simple example using an NSString, it can be applied using any other type of data as well - whether it be a collection or a custom data model object.",
thumbnail: {
sqDefault: "http://i.ytimg.com/vi/4nx7g60Ldig/default.jpg",
......

You have all the elements: title, thumbnail, link to page, etc... you need to PARSE (extract) this JSON response.. put it in an TableView..

at click on cell, open a new "Detail" page.. were you can have LBYouTubeView for iOS

Upvotes: 2

Jason
Jason

Reputation: 13986

If you can get a YouTube video to play in a UIView, you can embed that in a UITableView controller cell.

Upvotes: 1

Related Questions