Play local video file in UIwebview [closed]

≯℡__Kan透↙ 提交于 2019-12-13 10:42:06

问题


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

回答1:


Try this :

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


来源:https://stackoverflow.com/questions/24551251/play-local-video-file-in-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!