tags:

views:

71

answers:

1

hi I finally figured out how to display youtube video in uitableview,but the code i wrote leads to an youtube image button which is like an overlapped image. After i push the"youtube image button", it directs to a video player with "done" button. The youtube video is played quite fine. and it came back to the the previous page-youtube image button overlapped on uitableview when i push "done" button in youtube video player. My objective is to display youtube video by simply pushing a cell of uitableview and the page goes back to the same uitableview when i push the "done" button inside youtube video player. Below is my code. Can any one notice me how to revise the code to achieve my objective?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CGRect frame=CGRectMake(0, 0, 320, 240);
NSString *youtubelinkpath=@"http://www.youtube.com/watch?v=abx43GTD05o&feature=topvideos";
NSString* embedHTML = @"\
<html><head>\

<style type=\"text/css\">\

body {\

background-color: transparent;\

color: white;\

}\

</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, youtubelinkpath, frame.size.width, frame.size.height];
UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:html baseURL:nil];
[self.view addSubview:videoView];
[videoView release];
}
A: 

I just figured out that MPMoviePlayerController can play mp4 file which is on internet. If the link of mp4 file corresponding to specific youtube video is obtained, is it possible to play youtube video by MPMoviePlayerController? If it is so, all of my problem is solved immediately.

Alex