5
votes

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];
1
are you using size classes ?Starlord
Yes, I am using size classes.Mitesh Khatri
Seems like many have already asked this question in stack overflow [here][1] and [here][2] without much resolution ( or moving to a different library) [1]: stackoverflow.com/questions/25469142/… [2]: stackoverflow.com/questions/28527907/…shrutim
Didi try that? NSDictionary *playerVars = @{@"playsinline" : @1}; [playerView loadWithVideoId:videoID playerVars:playerVars];Piyush
Yes, I already tried this but no success. its working fine in the iPhone but no in the iPad.Mitesh Khatri

1 Answers

4
votes

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!