Is there anyway to autoplay online content audio file on ipad - iphone

I want to play audio file on ipad which is located on some server. but thing is I want to autoplay audio file using HTML5. Please suggest me the way.
Thanks

The autoplay attribute is purposely disabled on iPhone and iPad:
In Safari on iOS (for all devices,
including iPad), where the user may be
on a cellular network and be charged
per data unit, preload and autoplay
are disabled. No data is loaded until
the user initiates it. This means the
JavaScript play() and load() methods
are also inactive until the user
initiates playback, unless the play()
or load() method is triggered by user
action. In other words, a
user-initiated Play button works, but
an onLoad="play()" event does not.
Having said that there are some hacks for iOS 3 and iOS 4 to work around this with JavaScript. On iOS 3 you can create a link element and then simulate a click event to trigger the media element to play; on iOS4 you can simply call the load() and play() methods directly on the element.

Try this
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString:#"www.example.com/play.mp3"] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 10];
[myWebView loadRequest: request];
[request release];
Hope this helps!!!

Related

how to get YouTube Video URL

I am looking for Youtube Downloader app .and to download Video Firstly I need to get the URL of the Running video.How do I get the url of the video which i play.
but when I play any video into the simulator it automatically gives me some information of the url..which is
2013-02-21 12:25:26.518 MyTube[682:14003] [MPAVController] Autoplay: Enabling autoplay
2013-02-21 12:25:26.518 MyTube[682:14003] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
2013-02-21 12:25:26.518 MyTube[682:14003] setting movie path: http://r19---sn-a5m7lner.c.youtube.com/videoplayback?mt=1361429411&ipbits=8&fexp=919113%2C927902%2C916716%2C916612%2C901447%2C902545%2C920704%2C912806%2C902000%2C922403%2C922405%2C929901%2C913605%2C925006%2C906938%2C931202%2C908529%2C920201%2C930101%2C926403%2C901451&newshard=yes&key=yt1&signature=2AB1FC44B4EDA0C5DDF4E715FDCA19FFB16E0FF7.732382C58B3C8CBC4840D462940DFE2FEC9FBE53&source=youtube&sver=3&mv=m&expire=1361452937&ms=au&itag=36&el=watch&dnc=1&cp=U0hVRlRQUF9IUUNONV9MSlRKOjVNc1BwWTUxSVR2&upn=r3oQUqMCths&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&ip=117.215.128.101&app=youtube_mobile&ratebypass=yes&yms=0PtNsY21DUs&id=2a147a30c3da7601
that means setting movie path url which I needed ..but it comes automatically in the output ..do can i fetch this url ...so that I can download
I am just Playing youtube video into the Webview
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://m.youtube.com"]]];
You can use the YouTube API to fetch the URL. Take a look here and here
Youtube is a little bit tricky in iOS because it's doesn't provide the real video link that obvisioulsy.
There is a good plugin clalled LBYoutubeView which handles to extract the real url for you. You can have a look at the link extractor if you just want to download the video...
Another opportunity is to use the gdata objective c client and and import the extracted link in an UIWebView. But keep in mind that the gdata client doesn't provide you with the real link like the framework above.
And be aware, that UIWebivews in simulators < 6.0 probably do not support playing a youtube video in a UIWebview.
At least here is an example of how to embed a youtube video directly in an UIWebView:
[self.webView loadRequest:[NSURLRequest requestWithURL:
[NSURL URLWithString:
[NSString stringWithFormat:#"%#%#", #"http://www.youtube.com/embed/", #"THEYOUTUBEID"]]]];
You can use HCYoutubeParser:
https://github.com/hellozimi/HCYoutubeParser
NSString *videoUrl = [NSString stringWithFormat:#"https://www.youtube.com/watch?v=%#", videoId];
NSDictionary *videos = [HCYoutubeParser h264videosWithYoutubeURL:[NSURL URLWithString:videoUrl]];
videoUrl = videos[#"small"];

How to make vimeo video autoplay on iPhone/iPad?

I'm trying to embed a vimeo video into my app using UIWebView.
Currently my code looks like this and it plays the video fine if you press play, but I would like it to play when the UIWebView loads and I'm not sure how to make that happen.
NSURL *videoURL = [NSURL URLWithString:#"http://player.vimeo.com/video/123456?autoplay=1"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:videoURL];
UIWebView * SignUpVideo = [[UIWebView alloc] init];
MyVideo.frame = CGRectMake(0,125,781,481);
[self.view addSubview:SignUpVideo];
[MyVideo loadRequest:requestObj];
This is placed under -(void)viewDidLoad
The autoplay URL parameter doesn't work in Mobile Safari either. I'm thinking you may be out of luck unless you can get a URL for a direct stream. But in that case you could use the AVPlayer instead of a web view and have all of the flexibility you need.
Here is an interesting discussion about the vimeo direct link URLs: How can I find download links for vimeo videos? . However, according to that, vimeo doesn't allow that technique so you might want to take a look a the developer APIs here: https://developer.vimeo.com
Best regards.

Load YouTube outside Application

I have a simple UIWebView showing a page including YouTube thumbnail. When I click it, it loads it inside the application, but I want it to be loaded outside application in the YouTube-app.
How can this be done?
Thanks.
It should be as simple as loading the YouTube-video-url like this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.youtube.com/watch?v=abcde12345"]];
It won't work in the simulator because it doesn't have the YouTube-app, but it will work on the iPhone (i hope, untested).
(I also see that your accept-rate is pretty low, you should click the little ✔ next to the answer that you think is the best answer. That way people wondering about the same thing can find the most useful answer fast and the person posting the answer will be accredited.)
EDIT:
Here is an example of what you could do to catch the YouTube-urls and opening them in the YouTube-app instead of in your app:
- (BOOL)webView:(UIWebView *)wv shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
// Determine if we want the system to handle it.
NSURL *url = request.URL;
if ([url.host isEqual:#"youtube.com"] && ([url.query rangeOfString:#"watch"] != 0)) {
if ([[UIApplication sharedApplication]canOpenURL:url]) {
[[UIApplication sharedApplication]openURL:url];
return NO;
}
}
return YES;
}
This is not tested, but should work :)
From http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html
Method 2: Embed the YouTube player in a UIWebView
No, the iPhone still doesn't do Flash, but if you haven't already
noticed, the Safari browser on the iPhone is clever enough to turn any
YouTube embed into a clickable thumbnail that launches the native
YouTube player app on the phone. You can take advantage of this
feature in your app by using a UIWebView. Here's how:
Set up a UIWebView in your app. You can make it part of a xib or create it programmatically. Size the UIWebView according to how large
you want the clickable thumbnail to be.
Grab the video url using the same method as the one described above.
Call the loadHTMLString:baseURL: method on the UIWebView instance with some carefully constructed HTML that contains the YouTube
embedded player code snippet and some supporting HTML to make sure
that the video thumbnail appears correctly. Set the base URL to the
URL of your website (it doesn't do anything here -- ordinarily
UIWebView uses it to handle relative URL links correctly).
The best way to illustrate this is with a code snippet. Note the use
of the viewport HTML meta parameter and the consistent use of width
and height parameters throughout.
// webView is a UIWebView, either initialized programmatically or
loaded as part of a xib.
NSString *htmlString = #" ";
[webView loadHTMLString:htmlString baseURL:[NSURL
URLWithString:#"http://www.your-url.com"]];
One of the biggest benefits of this approach is that your app does not
have to quit in order for the video to start playing. In fact, the
iPhone will keep your app running in the background while it fires up
the YouTube player to play the video. After the video finishes playing
(or when the user hits "Done"), the user is automatically taken back
to your app. This experience is very similar to watching embedded
YouTube videos in the iPhone Safari browser and is just as seamless.

Use Vimeo videos inside iPhone/iPad app

our client's video archive is hosted on vimeo, so I want to know if it is possible to use vimeo videos inside of iOS app so that user could press button and get fullscreen video playing in default video player. Is there any kind of API available for that?
upd: I know that in 2010 there was same question on SO, but maybe things changed during last year.
Get the video id, and load it into a webview using the vimeo player url. It will open the quicktime player in full screen mode on tap of the play button.
urlAddress = [NSString stringWithFormat:#"http://player.vimeo.com/video/%#",videoID];
NSURL *url = [NSURL URLWithString:urlAddress];
self.requestObj = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestObj];
You can use YTVimeoExtractor to extract the mp4 url that is usable in MPMoviePlayerViewController.

How do you implement seeking using the AudioStreamer sample application as a base?

I need to play some audio streaming contents on iPhone, but there are some options and problems I can't solve:
1. http://cocoawithlove.com/2009/06/revisiting-old-post-streaming-and.html
It is a library provided by Matt Gallagher, but I saw the Limited scope, and I would play
a single song, not a radio station.
2. Suggestion from zonble
NSURL *URL = [NSURL URLWithString:#"http://zonble.net/MIDI/orz.mp3"];
NSData *data = [NSData dataWithContentsOfURL:URL];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithData:data error:nil];
But I need streaming for each "single song".
3. Using MPMoviePlayerController to wrapper.
Since the Class update new method, and
#interface MyAudioStreamer : UIViewController {
MPMoviePlayerController *mp ;
}
instead of [self addSubview:mp.view] I use my own xib file to implement play and
stop methods, but in this case, I have no idea to implement seekForward or seekBackward.
Is there any good idea to do AudioStreamer?
==== Update ====
after google 'AVPlayer' ,i used 3. Using MPMoviePlayerController to wrapper. to implement a auidoStreamer-like player ,there is something to share :
1.'playbackDidFinished' state
there're 2 conditions : a song did finished and play next song or a song interrupt by user press stop or exception, i used enum to filter my state.
2 multi-task playing your song in background
reference from https:// devforums.apple.com/message/264397
and if iOS SDK update, the solution might be changed because method would be diplicated. so i suggest to read library provided by Matt Gallagher.
anyone who konws when the library have no codec match download item (for example, my item encode by .AAC 128-bit and the library not support or at most .AAC 64-bit), what happen would the player be ?
You can either parse the icy meta data yourself, or if you're using iOS 4.0 you can playback using an AVPlayer and observe the timed metadata to discover the song boundaries and titles.