title: Embedding YouTube videos on
body: <p>I've embedded a video from YouTube via a snippet I've found on the Internet, here is the code that I've used:</p>
  
  <pre><code>    @interface FirstViewController (Private)
  - (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame;
  @end
  
  
  @implementation FirstViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      [self embedYouTube:@"http://www.youtube.com/watch?v=l3Iwh5hqbyE" frame:CGRectMake(20, 20, 100, 100)];
  }
  
  
  - (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
      NSString *embedHTML = @"\
      &lt;html&gt;&lt;head&gt;\
      &lt;style type=\"text/css\"&gt;\
      body {\
      background-color: transparent;\
      color: white;\
      }\
      &lt;/style&gt;\
      &lt;/head&gt;&lt;body style=\"margin:0\"&gt;\
      &lt;embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
      width=\"%0.0f\" height=\"%0.0f\"&gt;&lt;/embed&gt;\
      &lt;/body&gt;&lt;/html&gt;";
      NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
      UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
      [videoView loadHTMLString:html baseURL:nil];
      [self.view addSubview:videoView];
      [videoView release];
  }
  
  
  - (void)didReceiveMemoryWarning {
      // Releases the view if it doesn't have a superview.
      [super didReceiveMemoryWarning];
  
      // Release any cached data, images, etc that aren't in use.
  }
  
  - (void)viewDidUnload {
      // Release any retained subviews of the main view.
      // e.g. self.myOutlet = nil;
  }
  
  
  - (void)dealloc {
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>It compiles correctly and when I open it, I see a white box positioned incorrectly, which the code created. I have two questions regarding it:</p>
  
  <ol>
  <li><p>How do I know if the video will play, it is just a plain white box, does the simulator play videos from YouTube?</p></li>
  <li><p>How can I position this box?</p></li>
  </ol>