Student
Student

Reputation: 3

YTPlayerView doesn't always go to full screen

I am trying to show a youtube video but sometimes the YTPlayerView is being displayed in full screen and sometimes not. I want it to be always in full screen. How can I achieve it?

ytView = [[YTPlayerView alloc] initWithFrame:self.view.bounds];
ytView.backgroundColor = self.view.backgroundColor;
ytView.delegate = self;
NSDictionary *playvarsDic = @{ @"controls" : @1, @"playsinline" : @0, @"autohide" : @1, @"showinfo" : @1, @"autoplay": @1, @"modestbranding" : @1 };
[ytView loadWithVideoId:firstImage.Source playerVars: playvarsDic];

Upvotes: 0

Views: 829

Answers (2)

CodeChanger
CodeChanger

Reputation: 8351

To play youtube video in full screen you need to add one player property to play video in full screen.

fullscreen property: fs = 1 or 0

Update your dictionary like below:

NSDictionary *playvarsDic = @{ @"fs" : @1,
                                   @"controls" : @1,
                                   @"playsinline" : @0,
                                   @"autohide" : @1,
                                   @"showinfo" : @1,
                                   @"autoplay": @1,
                                   @"modestbranding" : @1 };

fullscreen property: fs

Setting this parameter to 0 prevents the fullscreen button from displaying in the player. The default value is 1, which causes the fullscreen button to display.

Check all player properties on this link: https://developers.google.com/youtube/player_parameters?playerVersion=HTML5

Hope this will help you to show your youtube video always in full-screen mode!

Upvotes: 0

AshokPolu
AshokPolu

Reputation: 645

Manually set playerView.webView.allowsInlineMediaPlayback = false in playerViewDidBecomeReady to force the player to go into webview.

Upvotes: 0

Related Questions