怎样用 UIWebView 的 loadHTML 方法加载一段 HTML 标签实现视频播放?
后台返回HTML 标签,内嵌视频,可以用浏览器打开,但是用 UIWebView 没有反应。代码如下
UIWebView *web = [[UIWebView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:web]; web.allowsInlineMediaPlayback = YES; web.delegate = self; self.web = web; NSString *str1 = @""; NSString *str2 = @""; NSString *content = @"
请问如何实现?多谢多谢
- (void)videoThumb:(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]; [webView loadHTMLString:html baseURL:nil]; [self.view addSubview:webView]; [webView release]; } //Include above function to your page and call it by passing the urlstring [self videoThumb:url:frame];
ref: http://stackoverflow.com/ques...