Incorporar Youtube Video en iPad

Here I put a small tutorial for embedded a youtube video on iPad also works on iPhone.

Note: The iPad/iPhone simulator does not allow online reproduction, the video will only be visible in a real device .

  1. First we create a View-based Application project.
  2. I will name it EmbeddedVideo, you can name it whatever you like.
  3. Open the EmbeddedVideoViewController.xib and added a UIWebView(drag and drop).

  4. Then in EmbeddedVideoViewController.h create an IBOutlet for ourUIWebView, leaving something like this:
    @interface EmbeddedVideoViewController : UIViewController {
       UIWebView *webVideo;
    }
    
    @property (nonatomic, retain) IBOutlet UIWebView *webVideo;
    
    @end
  5. We connect the IBOutlet with UIWebView, open the  EmbeddedVideoViewController.xib and  in File’s Owner in the Outlets section select/drag on our UIWebView:
  6. We opened in EmbeddedVideoViewController.m within viewDidLoad method (if commented, uncomment it) add a few lines of code, something like this:
    - (void)viewDidLoad
    {
           [super viewDidLoad];
           NSString *videoURL = @"http://www.youtube.com/watch?v=JOddp-nlNvQ";
           NSString *htmlString =[[NSString alloc] initWithFormat:@" ",videoURL];
           [webVideo setAllowsInlineMediaPlayback:YES];
           [webVideo loadHTMLString:htmlString baseURL:nil];
    }
  7. After that compile and run on our device and we’ll see something like this

I hope this will be useful and you can download the code from  here

One thought on “Incorporar Youtube Video en iPad

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos necesarios están marcados *

Puedes usar las siguientes etiquetas y atributos HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>