Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YTPlayerView Play video in full screen ipad

I am using "YTPlayerView" to play video in iOS. When I am using this in iPhone it automatically play video in full screen but when I am using same thing in the iPad it does not switch to full screen. I also tried the below parameters but no success.

NSDictionary *playerVars = @{ @"playsinline" : @0 };
[self.playerView loadWithVideoId:videoIDURL playerVars:playerVars];
like image 708
Mitesh Khatri Avatar asked Sep 27 '22 23:09

Mitesh Khatri


1 Answers

We have developed a very video intensive app for both iPhone and iPad in the past, and actually had the opposite problem - we wanted to use the YTPlayerView for displaying videos inline (non-fullscreen) on both devices, but weren't able to get it done on the iPhone. We ended up using XCDYouTubeVideoPlayerViewController, which seemed to have resolved most of our issues. This is not really the recommended way to approach this, since it pretty much breaks YouTube's terms of use (it parses the html page, finds the .mp4 url, and plays it in MPMoviePlayer, which gives all all of the flexibility you need for full screen, loading times and other notifications.

Throughout the process of trying to find a way to work with YTPlayerView, I contacted engineers form Google who work on the YouTube helper framework, and they recommended to work directly with the iframe player API, which lets you customize the controls and receive events about the video. This means you'll have to use your own web view instead of the YouTube helper. The communication between the JavaScript and the Objective-C parts can be tricky (and that's what the helper library actually tries to save from the developer), but it will give you more flexibility.

This can also help with working with UIWebView to display YouTube videos: Playing YouTube Videos in a WebView Inline.

I know it's not exactly what you asked, but I hope it can help lead you in the right direction. I've had a lot of issues working with YouTube videos on iOS, so I know how frustrating it can be. Good Luck!

like image 107
Rony Rozen Avatar answered Nov 15 '22 09:11

Rony Rozen