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.
Related
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.
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
I want to play a remote mp3 with AVPlayer. I can't make it work and I can't see the reason why it doesn't work. Code:
NSString *urlstr=#"..some link to a mp3"
NSURL *url=[NSURL URLWithString:urlstr];
self.player = [[[AVPlayer alloc] initWithURL:url] retain];
[player play];
The link is valid. If I load it in a webView it plays right away.
Please help.
I have get a solution. Please try the following code:
NSString *urlstr=#"http://www.3rdeyelab.com/mp3/mp3/tailtoddle_lo.mp3"
NSURL *url=[NSURL URLWithString:urlstr];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url];
player = [[AVPlayer playerWithPlayerItem:playerItem] retain];
[player play];
player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
Hope it will work for you!!!
If you use a local link as URL, so you should initiate url with fileURLWithPath method:
NSURL *url = [NSURL fileURLWithPath:urlstr];
The NSURLConnection class, regardless of whether the URL is local or remote, should always be used whenever a URL is concerned. It's the only thread-safe, non-intrusive means of loading a AVPlayerItem or AVAsset. Remember: your app shares the iPhone with other apps; and, this is the way to be responsible insodoing.
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.
I have an application that displays search tips. This will work if I store an .html file in the main bundle and display it using the Apple example code:
-(void)loadDocument:(NSString*)documentName inView:(UIWebView*)webView
{
NSString *path = [[NSBundle mainBundle] pathForResource:documentName ofType:nil];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
}
//load document --
[self loadDocument:#"searchTipsLegislators.html" inView:searchTips];
If however I change the document to one created using a compressed Pages file the app return the error:
2010-12-15 08:53:04.537 cv112[42067:7003] Cannot load iWorkImport
2010-12-15 08:53:04.538 cv112[42067:7003] Failed to generate preview
Has anyone gotten this to work?
Two things to try:
Don't compress the pages document. This is no longer necessary as of iOS 3.
Don't expect this to work on Simulator. Does it work on your device?