Important facts about commercial licenses

  • Licenses are perpetual. They do not expire and do not need to be renewed.
  • Licenses can be upgraded. You can upgrade to a more expensive license later paying only the difference in cost.
  • Pay attention to the distribution type - Hosted (sites / servers), binary (applications) or source (includes all the others). Choose according to your needs (more below).
  • All licenses allow commercial use unless otherwise indicated.
  • Read the full license by clicking on the icon.
  • Read more about licenses in our handy license guide.
$29

Single App License

1 application Binary restricted distribution 6 months support
$59

Developer License

Unlimited projects Source and binary distribution 1 year support
$79

Multiple App License

5 applications Binary restricted distribution 6 months support
You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

(5 ratings)

iOS YouTube View

iOS YouTube View
Developed by Markelsoft, Released May 30, 2012

A UIView for embedding a YouTube video. The video can be played in a window or full-screen. Custom thumbnails. Includes a demo.

Objective-C

Tags: ios6 , ipad , iphone , video

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.

It's tested and works fine on iOS6 but will work on any other version as well.

Back to top

Supported OS & SDK Versions

  • Supported build target - iOS 6.0 / Mac OS 10.7 (Xcode 4.3.1, Apple LLVM compiler 3.1)
  • Earliest supported deployment target - iOS 6.0 / Mac OS 10.6
  • Earliest compatible deployment target - iOS 6.0 / 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.

Back to top

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

Back to top

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;
Back to top

Example Project Demo

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

View all 4 reviews »

User Reviews

  • 1 of 1 people found this review helpful Td 6 months ago
    Excellent!!!
    Flag
    Was this helpful? Yes No
  • 0 of 1 people found this review helpful Adam R 7 months ago
    .
    Flag
    Was this helpful? Yes No
  • 0 of 1 people found this review helpful offtopic76 8 months ago
    Great
    Flag
    Was this helpful? Yes No
Read all 7 comments »

Questions & Comments


Or enter your name and Email
  • Richard Zenn 4 months ago
    Is it violating Youtube TOS when play video in specific window? Because I want to use this to embed custom subtiles.
    • Markelsoft Developer 4 months ago
      No because it is no different that copying the "embed" details when sharing a video on Youtube.
  • Chris Grundy 11 months ago
    Does this view support authenticated users watching private videos?
    • Markelsoft Developer 5 months ago
      It may -- I'll have to check. I say may as the view uses UIWebView so not sure if session cookies/authentication would pass through. I will run a test on one of my own videos that requires a login...
  • Jejo 1 year ago
    Hi, dose this code use webview or moviecontroller? or it is something new that will perform much faster than both of them?
    • Markelsoft Developer 1 year ago
      The code uses a UIWebView underneath and performs very well with minimal overhead.
    • Mark Petherbridge 10 months ago
      That is awesome. And really cheap! Actually quite glad i've found binpress
You must be logged-in to vote. Log-in to your account or register now.