How to get youtube embedded video in table view mode and get a problem when working with the "Finish" button

How can I get a YouTube video in a UITableViewCell and how can I handle the Done button of a UIWebView by playing a video?

I embedded the video in the form, but as in the image. And I want this Done button in this image:

Screen shot

I want to open a different screen when I return to viewing, and not to the previous view.

 -(void)viewDidLoad { [super viewDidLoad]; videoURL = [[NSString alloc]init]; videoURL =@ "http://www.youtube.com/watch?v=aE2b75FFZPI"; [self embedYouTube:videoURL frame:CGRectMake(10, 85, 300, 180)]; } - (void)embedYouTube:(NSString*)url frame:(CGRect)frame { NSString* embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: red;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>"; NSString* html = [NSString stringWithFormat:embedHTML, url, frame.size.width, frame.size.height]; if (videoView == nil) { videoView = [[UIWebView alloc] initWithFrame:frame]; [self.view addSubview:videoView]; NSLog(@"html%@",html); } [videoView loadHTMLString:html baseURL:nil]; } 

I need help. I did a search but got nothing.

+6
source share
2 answers

Since this remained unanswered, I thought I could offer an offer. The end result that I think is the same as what you are looking for, but the path to it is a little different.

So, from my understanding, you want the UITableView controller to display a list of YouTube videos that play when you click on them. This is how I processed this script in one of my applications.

  • You need to get the RSS feed of the video you want on your list. This is pretty easy ... if the user has the format http://www.youtube.com/rss/user/{USERNAMEβ–Ί/videos.rss
  • So, from there you need to parse the RSS feed into a list of objects that have a title, description, thumbnail and link to the video. All of this is provided in RSS, and I used NSXMLParser to do the job.
  • Once you have a good list of value objects to work with, all you have to do is turn off the MPMoviePlayerViewController column and pass it the URL to play the movie.

implemented didSelectRowAtIndexPath implementation

 - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { /** self.items is just a mutable array of video objects that is the underlying datasource for the table. The Video object is just a simple value object I created myself */ Video *video = [self.items objectAtIndex:[indexPath row]]; MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:video.video]]; [self presentMoviePlayerViewControllerAnimated:mp]; [mp release]; } 

This is what the interface looks like for my Video class

 @interface Video : NSManagedObject { @property (nonatomic, retain) NSString * title; @property (nonatomic, retain) NSString * link; @property (nonatomic, retain) NSString * comments; @property (nonatomic, retain) NSString * thumbnail; @property (nonatomic, retain) NSString * pubDate; @property (nonatomic, retain) NSString * video; @property (nonatomic, retain) NSString * guid; @property (nonatomic, retain) NSString * desc; @end 

This is pretty much a nice easy way to display YouTube videos in the UITableViewController. I will not understand XML parsing, there is a ton of documentation on how to do this. I just made a quick google and this blog really gets into the nuts and bolts that I'm talking about:

http://useyourloaf.com/blog/2010/10/16/parsing-an-rss-feed-using-nsxmlparser.html

Hope this helps you. I know that this does not apply to placing markup in WebView, but I think that you will find this method a little more intuitive and because there were no answers ... I hope it raises you up and starts.

0
source

What you want to do is related to the corruption of the media player used by UIWebView. This can be done by tracking the uiviewanimation notifications and then going through a bunch of subviews, but this will be due to the use of private methods and therefore is not recommended especially because the behavior of the private media player behaves with each os. I would recommend using jerrylroberts and getting direct links to a YouTube video.

0
source

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


All Articles