【问题标题】:Play local video file in UIwebview [closed]在 UIwebview 中播放本地视频文件 [关闭]
【发布时间】:2014-08-24 10:23:08
【问题描述】:

我无法在 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];

【问题讨论】:

标签: ios objective-c uiwebview


【解决方案1】:

试试这个:

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];

【讨论】:

  • 不,它对我不起作用。 @SGRKDL
  • 如果视频是应用程序包的一部分,那么您可以加载到 Web 视图中,但如果它在文档目录中,则无法在此处加载它是 link
  • 如果视频是应用程序包的一部分,那么您可以加载到 Web 视图中,但如果它在文档目录中,则无法加载它,这里是 link。这是一个替代方案 @987654323 @
猜你喜欢
  • 1970-01-01
  • 2011-06-17
  • 1970-01-01
  • 1970-01-01
  • 2011-01-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多