Houranis
Houranis

Reputation: 73

Launch Youtube app with a video

I have an app with a UIButton, I wish, when I click the button that the iPhone launches Youtube app with directly my video ready to start to play, I've tried this code:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=xxx"]];

But it launches Safari in the video page. I'm trying my app on actual device.

Thanks

Upvotes: 3

Views: 9999

Answers (2)

Ascendant
Ascendant

Reputation: 1004

As others have mentioned, this should indeed open the YouTube App- if you're testing it on your actual device.

Be aware that if you're running it in the simulator, it will open in Safari instead, as the simulator does not have the YouTube app.

Upvotes: 3

Patrick Perini
Patrick Perini

Reputation: 22633

Your code should be working fine, unless you're passing a bad YouTube link.

Make sure your URL begins with "http://www.youtube.com". That's the signifier for [UIApplication sharedApplication] to open the YouTube App.

Also check out this page about iOS URL schemes, and YouTube in particular.

Upvotes: 1

Related Questions