Lior Frenkel
Lior Frenkel

Reputation: 806

Play youtube full screen on landscape, but inline on portrait - on iPhone

I have a view with a UIWebView on half the size of the iPhone screen. In this webview I embed youtube videos. The app is only in portrait mode. Though I would like to see videos play also in landscape.

Now I want the following behaviour:

  1. When in portrait, play inline, don't go full screen. a. For that I use "webView.allowsInlineMediaPlayback=YES;" b. I open the webview with this link: "www.youtube.com/embed/videoid?playsinline=1"
  2. If the user rotates the screen to landscape, I'd like the video to go full screen.
  3. If the user then rotates back to portrait, I'd like the video to get inline again.
  4. The rotations shouldn't stop the video in the middle, or restart the play.

What should I do?

Upvotes: 0

Views: 3336

Answers (1)

patric.schenke
patric.schenke

Reputation: 972

As the embedded videos use an undocumented MPInlineVideo(Fullscreen)ViewController, you can't use its API and switch to fullscreen.

I'd thus recommend playing around with the "allowFullScreen"-parameter for the iframe-tag.

If everything fails, you should always be able to change the frame-size of the web-view so that it covers the full screen. You'd have to use width/height 100% in the iframe then.

Disclaimer: This is an educated guess. I've not actually tried to implement it that way.

Upvotes: 1

Related Questions