4

I am facing trouble to get the screen shot from the UIWebview when playing the video.

I am using the below code to play the video in UIWebView:

webViewHere.delegate=self;
webViewHere.scrollView.bounces = NO;
webViewHere.allowsInlineMediaPlayback = YES;
webViewHere.mediaPlaybackRequiresUserAction = NO;
NSURL *websiteUrl=[NSURL URLWithString:@"http://www.testapp.com/youtube21.html?videoid=wWWhOEtUBt4&st=7&en=27&height=270&auto=1&ctrl=0&p2p=1"];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:websiteUrl];
[webViewHere loadRequest:urlRequest];

I am using the below code to take the screen shot:

CGRect rect = [webViewHere bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[webViewHere.layer renderInContext:context];
UIImage *imageHere = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
screenShotImageView.image=imageHere;

I tried like this also.. same code but small change:

 CGRect rect=CGRectMake(0, 120, 320, 240);
 UIGraphicsBeginImageContext(rect.size);
 [webViewHere.layer renderInContext:UIGraphicsGetCurrentContext()];
 screenShotImage= UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();
 screenShotImageView.image=imageHere;

Please find the attached images, the screenshot appears when the video stops or when the video loading time. But when the video is playing it returns black screen. enter image description here

Please guide me, Thank in Advance

Babul
  • 1,268
  • 2
  • 15
  • 42

0 Answers0