I am trying to play a video from a website that I load inside my UIWebView in an iOS application developed with Objective C language.
When I hit the play button, I get an error message :
The video cannot be loaded, either because the server or network failed or because the format is not supported.
The code I've written for the web view is quite simple :
NSURL *url = [NSURL URLWithString:webSite];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webBrowser loadRequest:request];
The thing is that the same video is loading fine on Safari from the same device (iPad ).
Thanks!
(1) The video is not a web site. You might need to wrap it to a web page.
(2) If the video URL is not „https://„ it will fail playing since ios9 (?). You need to enable „Arbitrary Loads“ in your App‘s Info.plist.
Advice: Check option 2 first.
Related
I'm using WKWebView to show YouTube in my application.
When I load a youtube page it's sometimes open the YouTube App in my iPhone device.
This is the code I'm using:
NSURLRequest * req = [NSURLRequest requestWithURL:[NSURL URLWithString:#"https://www.youtube.com/"]];
[self.loginWebView loadRequest:req];
There is an option to detect the popup and prevent it?
I did want to post this as a comment but low rep won't let me. So, You might want to look at this topic:
Disable WKWebView for opening links to redirect to apps installed on my iPhone
I explored many sites and obtained the following instruction that displays a pdf file in a very beautiful way.
[_pdfViewer loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString: #"http://docs.google.com/gview?embedded=true&url=http://gamersgold.com/wop-ios/uploads/eula_terms.pdf"]]];
However this URL is mainly used in Android apps:
http://docs.google.com/gview?embedded=true&url=
When using it the Google Docs caption is displayed at the bottom of the page. Would using this method cause my app to be rejected by the App Store?
Is there any alternative approach to achieve this in iOS that is provided or approved by Apple?
Using this http://docs.google.com/gview?embedded=true&url= will not get your app rejected.
Still if you have doubt, it is not necessary to use this URl. You can directly code like below and it will display the PDF in UIWebView object. You can say this is an alternative, infact, the default way to display a PDF file in UIWebView
[_pdfViewer loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString: #"http://gamersgold.com/wop-ios/uploads/eula_terms.pdf"]]];}
I am trying to load webview for the following url http://www.topchickw.com/ but blank screen occured but same code is working for other url's
NSURL *myUrl = [NSURL URLWithString:#"http://www.topchickw.com/"];
NSURLRequest *myUrlRequest = [NSURLRequest requestWithURL:myUrl];
[self.myWebView loadRequest:myUrlRequest];
Can any one suggest me how to load webview of the particular url
Thanks in Advance
I am not an HTML expert. It seems that the URL when loaded is playing a flash video (.swf file). iOS does not support flash. Hence the blank screen.
To cross check this I try opening the URL in mobile safari browser, it did not work.
Hope that helps!
Well this url if you open manually in browser you will get blank window only. Please check the issue is not in the code.
A flash file runs when this url is loaded into browser. The issue is not with code but with the website as iOS doesnot support flash.
This question already has answers here:
How to redirect back to the caller app using custom url? [duplicate]
(2 answers)
Closed 9 years ago.
I have an app in which i want to open some already installed games on device.
For example I can open "Temple Run" using it's custom URL "templerun:/". Is there any way though to come back to my app from "Temple Run" which has custom URL suppose "testapp:/"?
Are there any other ways to achieve this, like using web view or something else?
You can't do this because other apps don't know and implement your app scheme. iOS doesn't supply such API by now.
x-callback-url is something match your want, appA open appB by scheme and appB callback-open appA. But this protocol is not official support by iOS.
That cannot be done .But you can use a webview inside app to show the webpage and do the rest
NSString *urlAddress = #”http://www.google.com”;
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
Or just go for some call back uri API method .
Does anyone know if there are any open source solutions out there that use UIWebview to build a full browser? There is something like this in Three20 when you pass a URL, but I am assuming there must be other alternatives out there.
I realize that UIWebView is a web browser, but hooking up refresh, back button, URL bar, etc will take extra time.
Suggestions?
SVWebViewController looks pretty much like what you're looking for.
I have started an open source project (MIT License) to make something as close as possible to the native MobileSafari application (on iPhone and iPad).
Here are the features so far :
Design close to Mobile Safari (iOS 4.x) native application (for both iPhone and iPad)
Bookmark support (support for folders in bookmarks not implemented yet)
Mail link support
Print web page support
Long tap handling (open or copy link) with customizable menu
Anyone wanting to contribute to this project is welcome to do it !
You can clone/fork the project here : https://github.com/sylverb/CIALBrowser
https://github.com/ghostery/banshee
EDIT the project is now maintained here: https://github.com/acatighera/banshee
It's an open source browser with tabs, bookmarks, search, etc.
UIWebView is a full browser ! To open a url in webView you do this -
NSURL *url = [NSURL URLWithString:webAddress];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webView loadRequest:req];
You can even insert javascript into UIWebView. You could customize it to your liking.
//To customize the look & feel...
self.webView.scalesPageToFit = YES;
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
self.webView.autoresizesSubviews = YES;
//To insert Javascript
NSString *jsCommand = [NSString stringWithFormat:#"document.body.style.zoom = 0.5;"];
[self.webView stringByEvaluatingJavaScriptFromString:jsCommand];
You could do lot more. Have fun...
UPDATE: To get a back button and all, webView provides those features, back, forward etc. all those browser features. You need to code up the buttons & UI & for code you could do this -
-(IBAction)goForward:(id)sender
{
[webView goForward];
}
-(IBAction)goBack:(id)sender
{
[webView goBack];
}
-(IBAction) gotoHome:(id)sender
{
NSString *urlAddress = #"http://google.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
You can also check out KINWebBrowser, a drop in web browser module for your apps.
https://github.com/dfmuir/KINWebBrowser
Features
iOS 7 & 8 support for iPhone and iPad
Customizable UI
Portrait and landscape orientation support
Use with existing UINavigationController or present modally
Load URL from NSURL or NSString
Delegate protocol for status callbacks
Action button to allow users to copy URL, share, or open in Safari & Google Chrome
Supports subclassing
Installation with CocoaPods