I am trying to load a Video in UIWebView. Video is stored in local file system. Here is the code snippet I am using for loading the video.
{
NSString* filePAth = [[NSBundle mainBundle] pathForResource:@"sample_iPod" ofType:@"m4v"];
NSLog(@"%@",filePAth);
NSData* data = [NSData dataWithContentsOfFile:filePAth];
[_webView loadData:data MIMEType:@"video/x-m4v" textEncodingName:@"UTF-8" baseURL:nil];
}
This is the error I get in console:
Error in Webview loading: Error Domain=WebKitErrorDomain Code=204 "Plug-in handled load" UserInfo=0x1f8b3c70 {NSErrorFailingURLStringKey=applewebdata://3F0047AD-E6CF-4EAD-A4C3-DA6E1C0BD603, WebKitErrorMIMETypeKey=video/x-m4v, NSErrorFailingURLKey=applewebdata://3F0047AD-E6CF-4EAD-A4C3-DA6E1C0BD603, NSLocalizedDescription=Plug-in handled load}
However, The same code works for loading all other file type for eg: PNG, DOC et.c.
Please help...!!!
Use the loadHTMLString(_:baseURL:) method to begin loading local HTML files or the loadRequest(_:) method to begin loading web content. Use the stopLoading() method to stop loading, and the isLoading property to find out if a web view is in the process of loading.
Overview. A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app's UI. A web view supports a full web-browsing experience, and presents HTML, CSS, and JavaScript content alongside your app's native views.
Step-1: Firstly, create a new project with a Single View App. Step-2: Then, open “Main. storyboard” and on your ViewController's view drag “Webkit View”. Select a WKWebView and place it on your view of a view controller.
You should load local videos and other videos whenever possible with MPMoviePlayerController
- (Documentation) - If playing the video is all you need and want and you are developing a native app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With