在UIwebview中播放本地视频文件 [英] Play local video file in UIwebview

查看:118
本文介绍了在UIwebview中播放本地视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I can't play local video file in UIWebview. Here is my code anything wrong? or Apple can't allow to play local video file in 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];

推荐答案

尝试一下:

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

这篇关于在UIwebview中播放本地视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆