I'm actually trying to play a local video into an UIWebView, with HTLM5.
What I do actually is this :
NSString *embedHTML = [NSString stringWithFormat:@"\ \ \ \ < src=\"%@\" \ \ ", [[NSBundle mainBundle] pathForResource:@"ash(1).mov" ofType:nil]]; [webView setOpaque:NO]; NSString *html = [NSString stringWithFormat:embedHTML, webView.frame.size.width, webView.frame.size.height]; [webView loadHTMLString:html baseURL:nil];
I have on my storyboard an UIWebView named webView with weak / nonatomic property
@property (weak, nonatomic) IBOutlet UIWebView *webView;
When I launch the app, nothing happen : the screen still white and no video is playing.
Use this:
NSString *embedHTML = [NSString stringWithFormat:@"
", [[NSBundle mainBundle] pathForResource:@"ash(1)" ofType:@"mov"]]; [webView setOpaque:NO]; //NSString *html = [NSString stringWithFormat:embedHTML, webView.frame.size.width, webView.frame.size.height]; NSURL *url = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"ash(1)" ofType:@"mov"]]; [webView loadHTMLString:embedHTML baseURL:url];
Refer more this to how to play video using html5
just change base url as
NSString *videoPath =[[NSBundle mainBundle] pathForResource:@"xxx" ofType:@"mov"]; NSString *htmlString=[NSString stringWithFormat:@" ", videoPath]; NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; [xwebview loadHTMLString:htmlString baseURL:baseURL];