0

I am using this code for loading video in UIWebView:

youTubeVideoHTML = @"<html><head>\
<body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";

videoWebView.delegate = self;
// Populate HTML with the URL and requested frame size
NSString *html = [NSString stringWithFormat:youTubeVideoHTML, videoURL, videoWebView.frame.size.width, videoWebView.frame.size.height];

// Load the html into the webview
[videoWebView loadHTMLString:html baseURL:nil];
[self.view addSubview:videoWebView];

It works fine, but on orientation change, it shows same width and height that in previous orientation.

If I use this code:

NSString *html = [NSString stringWithFormat:youTubeVideoHTML, videoURL, videoWebView.frame.size.width, videoWebView.frame.size.height];

// Load the html into the webview
[videoWebView loadHTMLString:html baseURL:nil];

in willAnimateRotationToInterfaceOrientation then video stops playing and reloads the URL.

Is there any way to resize the video without reloading the page?

jszumski
  • 7,430
  • 11
  • 40
  • 53
V.J
  • 189
  • 3
  • 17

1 Answers1

0

It may be because you don't have the body/html size defined so the percent doesn't know what to adjust to. See this post for more details:

height: 100% not working

Community
  • 1
  • 1
lehn0058
  • 19,977
  • 15
  • 69
  • 109