Created
February 10, 2014 07:45
-
-
Save yemaw/8911905 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/9060153/play-youtube-videos-in-iphone-app-without-using-uiwebview
modified the link pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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