I am trying to embed a video with the following code to avoid launching the youtube app and stay in my app:
-(void)embedYouTube:(NSString*)url frame:(CGRect)frame {
NSString* embedHTML = @"<iframe type=\"text/html\" width=\"64\" height=\"39\" src=\"http://www.youtube.com/embed/j8Bc7eRTdWY\" frameborder=\"0\"></iframe>";
if(videoView == nil) {
videoView = [[UIWebView alloc] initWithFrame:frame];
[movieDescView addSubview:videoView];
}
[videoView loadHTMLString:embedHTML baseURL:nil];
}
The problem is when I clicked on the play icon, it opens the youtube website with my uiwebview asking to install some web app . I would like to prevent this web app pop up to show or start the video full screen. Actually, any solution to show a youtube video without exiting my app would do.
I spent quite a bit of time looking through libraries and old code snippets; this library worked for me:
https://github.com/larcus94/LBYouTubeView
You don't use embed if you are trying to play the video. Just use the normal video URL so it will open in the iPhone's YouTube application rather than the web. If it opens in the web it will ask to install it's web app.
You need to change your HTML to this:
Or to launch it directly to the native app use the URL:
More Reference Information:
Apple Reference on URL Schemes
Apple Reference on Youtube Links
You can use this to load the movie (no needed to generate a html string):
The onely thing you have to looking for, is to use the "embed" link.
Tips:
where
stringUrl
is a video link of youtube ( ex. Youtube )