在UIwebview中播放本地视频文件

时间:2014-07-03 10:29:25

标签: ios objective-c uiwebview playback local-files

我无法在UIWebview中播放本地视频文件。这是我的代码有什么不对吗?或Apple不允许在UIWebview中播放本地视频文件。

NSString *webViewString = [NSString stringWithFormat:@"<!doctypehtml><html><head><title>SimpleMoviePlayer</title></head><body><videosrc=\"%@\">controls autoplay height=\"270\">
 width=\"1000\"></video></body></html>",pathOftheLocalFile];

UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(frame+(i*20), 0, 300, height)];

webview.allowsInlineMediaPlayback = YES;
webview.delegate = self;
[webview loadHTMLString:webViewString baseURL:nil];
[previewScrollView addSubview:webview];

1 个答案:

答案 0 :(得分:3)

试试这个:

NSString* htmlString = [NSString stringWithFormat:@"!DOCTYPE html>
<html lang="en">
<head>
<title>test</title>
<body>
<div>
<embed src="yourVideoName.mov" Pluginspage="http://www.apple.com/quicktime/" width="90%"   height="166px" CONTROLLER="true" LOOP="false" AUTOPLAY="false" name="IBM Video"></embed>
</div>
</body></html>"];

UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(frame+(i*20), 0, 300,   height)];
webview.allowsInlineMediaPlayback = YES;
webview.delegate = self;
[webview loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] bundleURL]];
[previewScrollView addSubview:webview];
相关问题