Powered By Blogger
Showing posts with label youtube. Show all posts
Showing posts with label youtube. Show all posts

Friday, November 23, 2012

how to add video url in webview as thumbnail in iphone ?

Hi friends,
This is the example for showing Video thumbnail icon in webview just as it appears in normal/youtube video list.

-(void)viewDidLoad
{
    UIWebView *webViewVideo = [[UIWebView alloc] initWithFrame:CGRectMake(0, (1024-500)/2, 768, 500)];
    [webViewVideo setBackgroundColor:[UIColor redColor]];
   
    UIButton* b=(UIButton*)sender;
   
    NSString* urlString=[array_Youtube objectAtIndex:b.tag];
   
    NSString *embedHTML = @"\
    <html><head>\
    <style type=\"text/css\">\
    body {\
    background-color: transparent;\
    color: white;\
    }\
    </style>\
    </head><body style=\"margin:0\">\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" \
    width=\"%0.0f\" height=\"%0.0f\"></embed>\
    </body></html>";
    NSString *html;
    html = [NSString stringWithFormat:embedHTML, urlString, 768.0, 500.0];
       
    [webViewVideo loadHTMLString:html  baseURL:nil];
    //UIView* v=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
    //[v addSubview:webViewVideo];
    //v.backgroundColor=[UIColor blackColor];
   
    [self.view addSubview:webViewVideo];
    [webViewVideo release];
}

 I hope this will be the useful to everyone of you.

Thanks,
Nilesh Prajapati