I want to play a quicktime movie in my app - iphone

I would like to play a quicktime movie in my app, can it be possible in webview or in any other view, my only resource is my quicktime link.

I already used a little trick to play audio files from URL in QuickTime. I guess it can work for movies files too. Here is my code :
NSString *url = #"http://my_url.com/my_movie_path/";
UIWebView* tempAudioPlayer = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
[tempAudioPlayer loadHTMLString:[NSString stringWithFormat:#"<iframe frameborder=\"0\" width=\"0\" height=\"0\" src=\"%#\"></iframe>", url] baseURL:nil];
[self addSubview:tempAudioPlayer];
I first create a UIWebView which will not be displayed. Then I loadHTMLString a <iframe> in it, with the URL of my file as the src value. And I add it to my view. Quicktime appears immediately.

NSString *url = "http://my_url.com/my_movie_path/AAA.mov";
UIWebView *tempAudioPlayer;
[tempAudioPlayer loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];

Related

how to play video in iphone for which url is coming from service

I want to play video in my iPhone.
NSString *myHTML = [NSString stringWithFormat:#"\<html>\<head>\<body>\%#</body>\</html>", summary];//here summary is my url
[webView2 loadHTMLString:myHTML baseURL:nil];
if I give the url statically its working fine iam able to play the video,but my url is coming from server like this
<iframe width="560" height="314' src="http://www.youtube.com" frameborder="0" allowfullscreen></iframe> // iam getting this from service.
if I proceed in the same way to load video its not working it's just showing total string in my view.
how to rectify this issue shall I need to get only source from that string(url)or is there any other way?
here i may get youtube video or mp4 or mov but not flash.(ios doesn't suppor)
It looks like your Service Response is in XML Format. First of all you need to do is to perform XML Parsing. For XML Parsing there are several Tutorials available. Some of the Links are :
Super easy iOS XML parsing
Parsing XML with Objective-C
How to Parse XML Files in Xcode
After parsing, Extract the data you want and Store it in some Variables or Arrays. Then use that data to play the Video. You can check these Links :
YouTube API Blog
Playing Video on the iPhone and iPad
Be Relax. It's so simple. Just follow the above steps and you will get the Result you want.
Update :
If your string look like myString mentioned in the below example then you can use the below code to get the URL.
NSString *myString = #"<iframe width="560" height="314'' src="http://www.youtube.com" frameborder="0" allowfullscreen></iframe>";
NSRange firstRange = [myString rangeOfString:#"http://"];
NSRange secondRange = [[myString substringFromIndex:firstRange.location] rangeOfString:#"""];
NSRange finalRange = NSMakeRange(firstRange.location, secondRange.location);
NSString *subString = [myString substringWithRange:finalRange];
NSLog(#"subString :: %#",subString);
GoodLuck !!!
1. If you want to play video in MPMoviePlayerController then use bellow code...
you can play video in MPMoviePlayerController like bellow...
MPMoviePlayerController *videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
videoPlayer.view.frame = CGRectMake(184, 200, 400, 300);
[self.view addSubview:videoPlayer.view];
[videoPlayer play];
see whole example from this link Code for Play Video in iPhone
Also see another Demo for play the video in iPhone from this link
AVPlayer
UPDATE :
2. If you want to play video in webView then use bellow code...
NSString *Str = #"<video controls> <source src=\"yourvideofile.mp4\"> </video>";
NSString *path = [[NSBundle mainBundle] pathForResource:#"yourvideofile" ofType:#"mp4"];
[Webview loadHTMLString:Str baseURL:[NSURL fileURLWithPath:path]];
i hope its useful to you...
just call add your string in this line your are good to go
[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"Your string"]]];

Show multiple PDF with one UIwebView

I hope someone can help me.
In one view of the app I've got a UIWebView where I'm showing the PDF file. I need to show 3 different PDF (a.pdf, b.pdf, c.pdf) in the same UIWebView. I know how to show one.
CGRect frame2 = CGRectMake(20, 25, 280, 350);
testWebView = [[UIWebView alloc] initWithFrame:frame2];
NSString *path = [[NSBundle mainBundle] pathForResource:#"a" ofType:#"doc"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[apneaWebView loadRequest:request];
[apneaWebView setScalesPageToFit:YES];
[self.view addSubview:testWebView];
But if are 3 different PDf what to do.
Thanks for any help.
Look at that: Can we display many pdf in a UIWebview?
You can only display a pdf in a UIWebView. You can try to create 3 different UIWebViews for every PDF or try to merge them.

Adding youtube video to my application

This is how i added a youtube video to my project; I have added these to the viewDidLoad Function
UIWebView *web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 480, 300)];
NSString *html = #"<html><head> .........."; // its too long so i cut it short
[webView loadHTMLString:html baseURL:[NSURL URLWithString:#"http://www.youtube.com/embed/vLBKOcUbHR0"]];
[self.view addSubview:web];
The view what i see is;
And what i want is some thing like this
If you look closer, you will see a ToolBar and a DOne button, and also a UIActivityIndicator in the second image, and none of these are displaying in mine. How can i solve this ?
That's not really how you use baseURL. The Base URL is what relative links will be relative to if there are links in the HTML - mapping it to youtube probably won't help at all.
Instead, just copy the embed code from youtube, which looks like this:
<iframe width="420" height="315" src="http://www.youtube.com/embed/2WNrx2jq184" frameborder="0" allowfullscreen></iframe>
Copy the URL from the iframe and open it directly in your web view, like this:
NSURL *URL = [NSURL URLWithString:#"http://www.youtube.com/embed/2WNrx2jq184"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
[webView loadRequest:request];
That should work.

How to read a pdf on ipad/iphone?

What is the way to read PDF content on an iPad or iPhone?
You can use Quartz to parse a PDF document and extract the metadata.
Parsing a PDF
There is another simple way to read a PDF in iPhone/iPad:
Take one UIwebView (name:pdfView).
Give Iboutlet connection to it & Delegate it to FilesOwner
In Viewdidload/VIewWillApper/VIewDidApper
[self.pdfView loadRequest:[NSURLRequest requestWithURL:
[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:#"ObjC" ofType:#"pdf"]]]];
ObjC.pdf should be in resource folder
Use fastpdfkit: https://github.com/mobfarm/FastPdfKit
Firstly, save a built in pdf file in document Directory of iPhone Simulator (say it demo.pdf). then use following code in ViewController.m file at ViewDidLoad method and dont forget to add UIWebViewDelegate in ViewController.h file
-(void) viewDidLoad
{
[super viewDidLoad];
UIWebView theWebView=[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
theWebView.delegate=self;
theWebView.scalesPageToFit=YES;
[self.view addSubview:theWebView];
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDir=[paths objectAtIndex:0];
NSString *fileName=[documentDir stringByAppendingPathComponent:#"demo.pdf"];
NSURL *url=[NSURL fileURLWithPath:fileName];
[theWebView loadRequest:[NSURLRequest requestWithURL:url]];
}

iPhone SDK: Preferences

I wanted an entire page of text(multiple lines) in my settings similar to the one on iphone:
settings->general settings->About->Legal
I have not been able to do so. I tried entering title in PSGroupSpecifier, it gives me multiple lines but with a gray background. i wanted a white background.
Any help would be highly appreciated.
Thanks in advance
Use a UIWebView and store your page as a HTML file in your resources.
// Create the UIWebView
UIWebView *webView = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease];
// Add the UIWebView to our view
[self.view addSubview:webView];
// Load the HTML document from resources
NSString *pagePath = [[NSBundle mainBundle] pathForResource:#"legal" ofType:#"html"];
NSURL *pageURL = [NSURL fileURLWithPath:pagePath];
NSURLRequest *pageReq = [NSURLRequest requestWithURL:pageURL];
[webView loadRequest:pageReq];