Play YouTube videos in iPhone app without using UIWebView?

Solution 1:

Just use XCDYouTubeVideoPlayerViewController. It seamlessly adds youtube video to your app without the need of UIWebView.

It uses progressive download + MoviePlayer and AVFoundation frameworks. Just supply it with a youtube video ID and you are good to go.

It supports both full-screen & non full-screen and WORKS ON iOS SIMULATOR!!!

Example:

XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"9bZkp7q19f0"];
[self presentMoviePlayerViewControllerAnimated:videoPlayerViewController];

Solution 2:

There is now a YTPlayerView class available with the YouTube Data API (v3).

Have a look at Using the YouTube Helper Library to embed YouTube videos in your iOS application

It gives comprehensive instructions on how to install the helper library, and incorporate YTPlayerView into your storyboard.

Solution 3:

Mr.Yuvaraj.M your above code is correct. Please run the project in your iPhone/iPod touch device. The youtube videos may not support/not work in Simulator. Please check on this. Thanks.