Alex Rivera | Logout

How do I launch a YouTube video in my iPhone app?

Asked 2011-03-25T23:30:21.580
9

On my app I need a button, so when it's tapped a youtube video is launched.

So how can I achieve this?

Edit
Report

1 Answer

11

The iOS device has URL schemes that it recognize. Build your youTube url like the following:

http://www.youtube.com/watch?v=VIDEO_IDENTIFIER

That will launch the youTube player on the device.

NSString *videoName = @"1JynBEX_kg8";
NSString *string = [NSString stringWithFormat:@"http://www.youtube.com/watch?v=%@", videoName];
NSURL *url = [NSURL URLWithString:string];
UIApplication *app = [UIApplication sharedApplication];
[app openURL:url];

For more information on iOS URL Scheme Apple URL Scheme Reference.

answered 2011-03-25T23:46:27.703

Your Answer