Download YouTube channel GData for a separate video by ID

I am trying to play a YouTube video in UIWebView instead of leaving my application.

Google thinks easy peasy- http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html

So, I have a GData structure and headers that work well, and I have no problem doing queries, loading custom video streams, etc.

But what I can not do is upload a specific video. I know the video IDs that I want the channels to be in advance . How to download a specific video?

Then I will follow google instructions:

Grab the video url from the media tag in the API response with the application/x-shockwave-flash type.  

and then paste it like this:

// webView is a UIWebView, either initialized programmatically or loaded as part of a xib.

NSString *htmlString = @"<html><head>
<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head>
<body style=\"background:#F00;margin-top:0px;margin-left:0px\">
<div><object width=\"212\" height=\"172\">
<param name=\"movie\" value=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"></param>
<param name=\"wmode\" value=\"transparent\"></param>
<embed src=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"
type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"212\" height=\"172\"></embed>
</object></div></body></html>";

[webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.your-url.com"]];

Any help would be greatly appreciated!

+3
2

YouTube URL- Flash :

for (GDataEntryYouTubeVideo *videoEntry in [feed entries]) {
  GDataYouTubeMediaGroup *mediaGroup = [videoEntry mediaGroup];
  NSString *videoID = [mediaGroup videoID];

  NSArray *mediaContents = [mediaGroup mediaContents];
  GDataMediaContent *flashContent =
    [GDataUtilities firstObjectFromArray:mediaContents
                               withValue:@"application/x-shockwave-flash"
                              forKeyPath:@"type"];

  NSLog(@"video ID = %@, flash content URL = %@",
        videoID, [flashContent URLString]);   
}
+6

. , API- - . , ...

http://code.google.com/apis/youtube/2.0/developers_guide_protocol_video_entries.html

, ATOM GData URL- "UIWebView".

... Grobbins, !

+2

Source: https://habr.com/ru/post/1773366/


All Articles