YouTube View for iOS

YouTube View for iOS

Released 5 years ago , Last update 4 years ago

A UIView for easily embedding a YouTube video. The video can be played in a window or full-screen, and have a custom thumbnail. This package includes full source code and a working demo.

UIYouTubeView is UIView subclass which creates a view for embedding a YouTube video. For iPad, iPhone and iPod Touch.

YouTube videos used can be referenced by YouTube video url or id.

The YouTube video can fully fit the view or a specific width and height can be specified. A preview video frame is shown for the view with the YouTube classic play and logo overlaid.

The embedded view player has the full YouTube player function.

In addition to playing the video within the video you can also launch the iOS YouTube app to play the associated video, if you like.

iOS Support

This project supports iOS 7, iOS 8 and iOS 9.

4.2
  • 5 3
  • 4 0
  • 3 2
  • 2 0
  • 1 0
5 Reviews Read Reviews

Pricing

14 day 14-day money-back guarantee

$19.99

Single App

  • Perpetual license

  • 1 application

  • Can distribute binary products only

  • Commercial use

  • 6 months support

$59.99

Developer

  • Perpetual license

  • Unlimited projects

  • Can distribute code and binary products

  • Commercial use

  • 6 months support

Supported OS & SDK Versions

  • Supported build target - iOS 7.0, iOS7 and iOS 9.0- / Mac OS 10.7 (Xcode 4.3.1, Apple LLVM compiler 3.1)
  • Earliest supported deployment target - iOS 6.1 / Mac OS 10.6
  • Earliest compatible deployment target - iOS 6.1 / Mac OS 10.6

NOTE: 'Supported' means that the library has been tested with this version. 'Compatible' means that the library should work on this OS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly.

Installation

To use UIYouTubeView into your app, drag the UIYouTubeView.h, UIYouTubeView.m into your project. Make sure that you indicate to copy the files into your project. Also make sure that the Target Membership is checked UIYouTubeView.m

Usage

// see Demo Example in Examples/Demo folder for full source code

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];

self.navigationItem.title = @"UIYouTubeView Demo";  

CGRect rect = [[UIScreen mainScreen] bounds];
screenWidth = rect.size.width;
screenHeight = rect.size.height;

self.view.backgroundColor = [UIColor blueColor];

NSURL * _videoUrl = [NSURL URLWithString:@"http://www.youtube.com/watch?v=KSrdUSlf7_c"];
videoView1 = [[UIYouTubeView alloc] initWithFrame:CGRectMake(140, 20, screenWidth - 280, 240) videoUrl:_videoUrl];
[videoView1 setUseRoundCorners:TRUE];
[self.view addSubview:videoView1];    

videoView2 = [[UIYouTubeView alloc] initWithFrame:CGRectMake(200, 300, screenWidth - 400, 200) videoUrl:_videoUrl videoWidth:180 videoHeight:180];
[videoView1 setUseRoundCorners:TRUE];
[self.view addSubview:videoView2];    

videoView3 = [[UIYouTubeView alloc] initWithVideoId:CGRectMake(100, 540, screenWidth - 200, 300) videoId:@"NrRNwLJHxhQ"];
[videoView3 setUseRoundCornerRadius:30];
[self.view addSubview:videoView3];    

// dump out some of the details or the first video...
NSLog(@"video url: %@", [videoView1 getVideoUrl]);
NSLog(@"video id: %@", [videoView1 getVideoId]);
NSLog(@"video width: %d height: %d", [videoView1 getVideoWidth], [videoView1 getVideoHeight]);
NSLog(@"page HTML: '%@'", [videoView1 getPageHTML]);
NSLog(@"embed HTML: '%@'", [videoView1 getEmbedHTML]);    
NSLog(@"iframe embed HTML: '%@'", [videoView1 getIFrameEmbedHTML]);    
NSLog(@"object embed HTML: '%@'", [videoView1 getObjectEmbedHTML]);    

/**
// Example of opening in YouTube app
[videoView1 openInYouTubeApp];

// Example of video taking up most o screen...

NSURL * _videoUrl = [NSURL URLWithString:@"http://www.youtube.com/watch?v=KSrdUSlf7_c"];
videoView1 = [[UIYouTubeView alloc] initWithFrame:CGRectMake(20, 20, screenWidth - 40, screenHeight - 100) videoUrl:_videoUrl];
[videoView1 setUseRoundCorners:TRUE];
[self.view addSubview:videoView1];  
 **/
}



// create UIYouTubeView with YouTube video url...
- (id)initWithFrame:(CGRect)frame videoUrl:(NSURL *)_videoUrl;

// create UIYouTubeView with YouTube video url and video width and height...
- (id)initWithFrame:(CGRect)frame videoUrl:(NSURL *)_videoUrl videoWidth:(int)_videoWidth videoHeight:(int)_videoHeight;

// create UIYouTubeView with YouTube video id...
- (id)initWithVideoId:(CGRect)frame videoId:(NSString *)_videoId;

// create UIYouTubeView with YouTube video id and video width and height...
- (id)initWithVideoId:(CGRect)frame videoId:(NSString *)_videoId  videoWidth:(int)_videoWidth videoHeight:(int)_videoHeight;


// set whether to use round corners or not.
- (void)setUseRoundCorners:(BOOL)_useRoundCorners;

// set the radius to use for round corners.   10 is the defaults.  The larger the number the rounder the corners.
- (void)setUseRoundCornerRadius:(int)_radius;

// set the video url used
- (void)setVideoUrl:(NSURL *)_videoUrl;

// get the video url used
- (NSURL *)getVideoUrl;

// set the video id used
- (void)setVideoId:(NSString *)_videoId;

// get the video url used
- (NSString *)getVideoId;

// set the video width
- (void)setVideoWidth:(int)_videoWidth;

// get the video width used
- (int)getVideoWidth;

// set the video height
- (void)setVideoHeight:(int)_videoHeight;

// get the video height used 
- (int)getVideoHeight;

// get the full page HTML for the YouTube video...
- (NSString *)getPageHTML;

// get the embed HTML for the YouTune video...
- (NSString *)getEmbedHTML;

// get the IFrame embed HTML for the YouTune video...
- (NSString *)getIFrameEmbedHTML;

// get the Object embed HTML for the YouTune video...
- (NSString *)getObjectEmbedHTML;

// get a named param value for the video url..
- (NSString *)getVideoUrlParam:(NSString *)_name;

// open url in YouTube app...
- (void)openInYouTubeApp;

Example Project Demo

The UIYouTubeViewDemo example in the Examples/Demo folder demonstrates using UIYouTubeView.

3 licenses, starting from From » $19.99 View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


Or enter your name and Email
  • SK Sergey Kargopolov 3 years ago
    Can I control playback by creating my own buttons Play and Pause? or the only way user can play and pause is to use controls available by default?
  • ON oren nia 4 years ago
    Hi ! Is the auto-play issue resolved ? Oren
    • Thomas A. Markel Publisher 3 years ago
      no the auto-play is a problem inherent to embedding the YouTube player in an iOS UIWebView. Nothing I can do to fix it. Apple unfortunately disables autoplay in a UIWebView because of their concerns over mobile bandwidth use age (I.e a video begins playing when the page is loaded, and the user is on a cellular network, and it gobbles up their data). Also see Google documentation referring to Apple Safari browser and Google's Chrome browser. https://developers.google.com/youtube/iframe_api_reference#Mobile_considerations
  • PA Paulo Ayala 4 years ago
    does it allow to play videos in HD?