Embed Youtube in UIWebView behind transparent img. Wmode transparent and z-index doesn't work

Posted by Allisone on Stack Overflow See other posts from Stack Overflow or by Allisone
Published on 2010-06-10T01:05:58Z Indexed on 2010/06/10 1:12 UTC
Read the original article Hit count: 572

Filed under:
|
|
|

I'm using this code:

- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
  NSString *embedHTML = @"\
  <html><head>\
  <style type=\"text/css\">\
  body {\
  background-color: black;\
  }\
  #container{\
  position: relative;\
  z-index:1;\
  }\
  #video,#videoc{\
  position:absolute;\
  z-index: 1;\
  border: none;\
  }\
  #tv{\
  background: transparent url(tv.png) no-repeat;\
  width: 320px;\
  height: 205px;\
  position: absolute;\
  top: 0;\
  z-index: 999;\
  }\
  </style>\
  </head><body style=\"margin:0\">\
  <div id=\"tv\"></div>\
  <object id=\"videoc\" width=\"240\" height=\"160\">\
  <param name=\"movie\" value=\"%@\"></param>\
  <param name=\"wmode\" value=\"transparent\"></param>\
  <embed wmode=\"transparent\" id=\"video\" src=\"%@\" type=\"application/x-shockwave-flash\" \
  width=\"240\" height=\"160\"></embed>\
  </object>\
  </body></html>";
  NSString *path = [[NSBundle mainBundle] bundlePath];
  NSURL *baseURL = [NSURL fileURLWithPath:path];      
  NSString *html = [NSString stringWithFormat:embedHTML, urlString,urlString];
  UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
  [videoView loadHTMLString:html baseURL:baseURL];
  [self.view addSubview:videoView];
  [videoView release];      
}

Its the first time that I use UIWebView and the first time that I use video in iPhone. The video plays, so that's working BUT:

I want to have an old school tv (round corners) in foreground with switches and so on. The tv is an image with transparent pixels in the middle, so that a video lying behind the tv will shine through as if the video would be shown on the tv.

But first of all the video has a border that I can't remove and second it's always in the foreground. In Safari and in Firefox and Mac it's working. So is it an iPhone thing, could it be that it simply won't work on iPhone ? Or do I have some css/html typos ?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiwebview