I have tried this following code to open youtube videos,its not working may i know the reason,
NSString *yo开发者_开发百科uTubeVideoHTML = @"<html><head>\
<body style=\"margin:0\">\
<embed id=\"yt\" src=\"http://www.youtube.com/watch?v=gczw0WRmHQU\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
Thanks in advance
I guess you're loading that string into a webview, don't you?
/**
* Embeds the youtube HTML data into the webview
*/
- (void)embedYouTubeIntoWebview:(UIWebView *)webView
withURL:(NSString *)url
inFrame:(CGRect)frame {
webView.delegate = self;
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, url, frame.size.width, frame.size.height];
[webView loadHTMLString:html baseURL:nil];
}
Remember that this won't work with the emulator. You need to test it in real device.
精彩评论