开发者

MJPEG in UIWebView - How to change scale with javascript (iphone)

开发者 https://www.devze.com 2023-01-13 12:39 出处:网络
I\'m displaying an MJPEG stream in a UIWebView.I have two different sizes I want to use for the UIWebView.The video size is constant.

I'm displaying an MJPEG stream in a UIWebView. I have two different sizes I want to use for the UIWebView. The video size is constant.

So setScalesPageToFit isn't flexible enough, and I have no control开发者_运维问答 over the source to change the viewport meta tag. So I'm left thinking that I need to do this via javascript (of which I have very little knowledge). However I'm stuck with two issues:

1) What javascript to call to change the scale/width of the uiwebview. I've tried variations on:

[webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.width='320px'"];

[webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTransform='scale(1.0)'"];

2) I can't stringByEvaluatingJavaScriptFromString from webViewDidFinishLoad, since this doesn't get called when streaming. So I'm calling it straight after my loadRequest.

[edit] I've also now tried calling this a couple seconds later via NSTimer (although i can't really use this approach since I don't know when the video feed arrives). Anyway I see some impact on the scale, but the next frame that arrives seems to reset the scale.


I've recently revisited this and now use a transform on the containing view

0

精彩评论

暂无评论...
验证码 换一张
取 消