-2

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];
Braiam
  • 1
  • 11
  • 47
  • 78
Rajesh Kumar
  • 821
  • 12
  • 20

1 Answers1

3

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];
SGRKDL
  • 106
  • 1
  • 2
  • No, it can't work for me. @SGRKDL – Rajesh Kumar Jul 04 '14 at 06:16
  • If the video is part of the app bundle then you can load into the web view but if its in documents directory you can't load it here is the [link](https://lh5.googleusercontent.com/-E04kqghLhYk/V7W1aWfKtTI/AAAAAAAAGUo/xavby-jUx7oIP7nGHXa42-f1GeIq5LaWACL0B/w1500-h162-no/Console.png) – Durai Amuthan.H Aug 29 '16 at 09:50
  • If the video is part of the app bundle then you can load into the web view but if its in documents directory you can't load it here is the [link](https://lh5.googleusercontent.com/-E04kqghLhYk/V7W1aWfKtTI/AAAAAAAAGUo/xavby-jUx7oIP7nGHXa42-f1GeIq5LaWACL0B/w1500-h162-no/Console.png).Here is an alternative [solution](http://stackoverflow.com/a/39032697/730807) – Durai Amuthan.H Aug 29 '16 at 09:52