going for the next youtube video in my iphone app - objective-c

i'm developing an iphone app which can play youtube links using a web view
Every things fine. but except it goes to the next video automatically. is thr any way to stop this.
Here is my code.
NSString *urlAddress = #"http://www.youtube.com/embed/wh0ZK5QJMWk"; //http://www.youtube.com/embed/wh0ZK5QJMWk
NSURL *url = [[[NSURL alloc] initWithString:urlAddress] autorelease];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestObj];
Thanks

Related

Force youtube video from UiView to play

I'm creating an app which include youtube videos. For this app i need a way to force the youtube video to open. how can i force it to start?
i've looked at this:
webView.userInteractionEnabled = NO;
But cant seem to figure out how to use it.
This is the code:
stringUrl = [NSString stringWithFormat:#"http://www.youtube.com/watch?v=%#", youtubeId[0]];
headerTitle.text = [NSString stringWithFormat:#"%#", theTitle[0]];
NSURL *url = [NSURL URLWithString:stringUrl];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
Here you will get working example project in which it is using HCYoutubeParser to parse the youtube url
https://github.com/hellozimi/HCYoutubeParser
form here you can down load working code and you can check it on simulator and iphone both
even it will explain how to use it.

Open iTunes Store within IOS App just like in twitter music

This code separately open Itunes .
NSURL *url = [NSURL URLWithString:#"https://itunes.apple.com/us/album/gravity-voice-performance/id631561174?uo=4"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_webView loadRequest:requestObj];
I want to open Album page within ios app.
Have a look at SKStoreProductViewController.

How to Stop UIWebView from playing mp3?

I am loading a MP3 file into UIWebView control on an iPad Application, I have a UIButton called done the user expected to dismiss the UIWebView and stop the music, here is a code snippet:
// points to the mp3 file path
NSURL *url = [NSURL fileURLWithPath:self.sFilePath];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[web loadRequest:request];
When the user hit done I do the following:
[self.webview removeFromSuperview];
[self.webview release];
But that does not stop the music from playing, I noticed that loading mp3 files on UIWebView opens the QuickTime player is that correct way?
I am greatly appreciative of any guidance or help.
Looks like a dupe of Video/audio streaming does not stop even if UIWebView is closed - iPad
The solution there:
[self.webContent loadRequest:NSURLRequestFromString(#"about:blank")];
I suggest that you play the sound yourself using for example AVAudioPlayer (probably the easiest way to play and control sounds in iOS).
Something like this:
NSURL *url = [NSURL fileURLWithPath:self.sFilePath];
NSData *mySound = [NSData dataWithContentsOfURL:url];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithData:mySound error:NULL];
audioPlayer.numberOfLoops = 0;
[audioPlayer play];
You can then stop the sound as simple as:
[audioPlayer stop];
or
[audioPlayer pause];
Don't forget to include the AVFoundation.framework in your project.

ipad app opens browser in the background

Im using the openURL command to send an SMS, but it opens the safari,
can I send the command so it opens in the background??
ie, the user dont see the browser opening or the message that it gives, and stays in the app,
NSURL *url = [NSURL URLWithString: #"https://smsgw.exetel.com.au/sendsms/api_sms.php?username=xxx&password=xx&mobilenumber=0xxx&message=xxr&sender=mk&messagetype=Text&referencenumber=04"];
[[UIApplication sharedApplication] openURL: url];
Thank you
You can't have Safari open a URL for you in the background. But supposing you just want to request the URL and ignore whatever comes back, you could try:
NSURL *url = [NSURL urlWithString:#"...whatever..."];
NSURLRequest *request = [NSURLRequest requestWithURL:url delegate:nil];
NSURLConnection *connection = [NSURLConnection connectionWithRequest:request];
[connection start];
You can do this be creating a UIWebView inside your app, and calling loadRequest: on the instance, like this:
UIWebView *webView = [[UIWebView alloc] init];
webView.delegate = self;
NSURL *url = [NSURL URLWithString: #"https://smsgw.exetel.com.au/sendsms/api_sms.php?username=xxx&password=xx&mobilenumber=0xxx&message=xxr&sender=mk&messagetype=Text&referencenumber=04"];
NSUrlRequest *request = [[NSUrlRequest alloc] initWithURL:url];
[webView loadRequest:request];
This will load the URL inside the app, without sending you over to Mobile Safari. The benefit of this method over NSUrlConnection is that if you conform to the UIWebViewDelegate protocol and implement webViewDidFinishLoad: in your delegate class, you can see if the call succeeded or not.

IPad App Issue - Webview

I developing a Ipad application I am trying to use Webview but not able to open the URL in webview I am using following code
NSURL *fileURL = [[[NSURL alloc] initWithString:#"http://www.google.com/"] autorelease];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:fileURL];
[webview loadRequest:requestObj];
this code working well for Iphone app not not working for Ipad app. Is anything wrong.
Thanks Amit Battan
Did you initialize webView object?
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,100,100)];