I am new here and I had read different posts but could not find an answer to my problem. I have a program where I load html content or website into UIWebview and it could have video.
I want user to be able to do screenshot of html and video programatically in order to send. Where video is playing I want to add a watermark on it but not on the whole html. I know that I will get black screen when taking screenshot programmatically but that's ok I will fix that after.
I had followed this post https://stackoverflow.com/a/26155153/4096376 I am able to access to AVPlayerItem using Notifications Center and get video size on screen (playbackSize = playerItem.presentationSize). However, I would like to know also the video position on screen in order to place the watermark.
It seems the only way to get video position is to have access to AVPlayer playback then AVPlayerLayer and videoRect property. Here AVPlayer is created by UIWebview so I don't know how to access it.
Anyone knows how to achieve this or any better way to do? Many thanks.
After few days of searching I found simpler solution by evaluating html itself to get video element position.
int videoYPosition = [[webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('video')[0].getBoundingClientRect().top + window.pageYOffset - document.documentElement.clientTop"] intValue];
NSLog(@"videoYPosition: %d", videoYPosition);
int videoXPosition = [[webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('video')[0].getBoundingClientRect().left + window.pageXOffset - document.documentElement.clientLeft"] intValue];
NSLog(@"videoXPosition: %d", videoXPosition);
You may need to loop to get right video if you have many on your html.