Question

I have been looking through the Google docs on how to get a JSON list of videos for a channel. And I figured out how to get the videos list with thumbnails and title and so on..... but nowhere can I find how to get a VIDEO MP4 (or whatever other format) URL's.

You see I need to play the videos in a iOS app and my app needs the actual VIDEO URL not some annoying url which just returns a list of thumbnails or playlists...

I found these instructions online and they work apart from the last part:

You have to get the upload playlist id to get each videos uploaded. To get that, you need to get the channel id. After you have the playlist id from the channel id, it is pretty simple. I have written out the steps for all three below.

Also, we offer PubSubHubBub which allows you to be alerted every time a new video is added to a channel, or you could use SUP (V2) to see which resources have changed before making the calls.

Instructions to get video ids for all uploaded videos for a channel in V3

Get the channel id for the channel you want (you probably only need to do this once, then you can save it)

Use search.list Set type to channel Set q to the name of the channel you want Grab the channel id (something like this: "channelId": "UC0X2VuXXXXXXXXXXXXXXXX") Get the playlist id for the channel uploads using the channel id from step 1 (you probably only need to do this once, then you can save it)

Use channels.list Set id to UC0X2VuXXXXXXXXXXXXXXXX from step 2 Grab the uploads key from contentDetails (something like this: "uploads": "UU0XXXXXXXXXXXXXXXXXXXX") Get the videos via the playlistitems in the playlist using the playlist id from step 2

Use playlistItems.list Set playlistId to UU0XXXXXXXXXXXXXXXXXXXX from step 2 Go through each PlaylistItem and pull out the video id

As you can see the very LAST part says to go through thr playlistitem and pull out the video id. I have done that, but what do I need to do with the video id in order to get the video URL???

Can anyone help me?

Thanks, Dan.

Was it helpful?

Solution

      NSString *youtubeHTML = [[NSString alloc] initWithFormat:@"\
                             <html><head>\
                             <style type=\"text/css\">\
                             body {    background-color: transparent;\
                             color: white; \
                             }\
                             </style>\
                             </head><body style=\"margin:0\">\
                             <iframe class=\"youtube-player\" width=\"280\" height=\"210\" src=\"http://www.youtube.com/embed/%@?\" frameborder=\"0\" allowfullscreen=\"true\"></iframe>\
                             </body></html>", videoID];

You can also use the URL to show/hide stuff, hd, start at a certain time.

youTubeView = [[UIWebView alloc] initWithFrame:CGRectMake(yourframe)];
[youTubeView loadHTMLString:youtubeHTML baseURL:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top