Skip to content

Instantly share code, notes, and snippets.

@yemaw
Created February 10, 2014 07:45
Show Gist options
  • Save yemaw/8911905 to your computer and use it in GitHub Desktop.
Save yemaw/8911905 to your computer and use it in GitHub Desktop.
[self playVideo:@"http://www.youtube.com/v/WL2l_Q1AR_Q" frame:CGRectMake(20, 70, 280, 250)];
- (void)playVideo:(NSString *)urlString frame:(CGRect)frame
{
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, urlString, frame.size.width, frame.size.height];
UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:html baseURL:nil];
[self.view addSubview:videoView];
[videoView release];
NSLog(@"%@",html);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment