0

我正在尝试显示 youtube 视频,但有时 YTPlayerView 会全屏显示,有时不会。我希望它始终全屏显示。我怎样才能实现它?

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];
4

2 回答 2

0

要全屏播放 youtube 视频,您需要添加一个播放器属性以全屏播放视频。

fullscreen property: fs = 1 or 0

更新您的字典,如下所示:

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

全屏属性:fs

将此参数设置为 0 可防止播放器中显示全屏按钮。默认值为 1,这会导致显示全屏按钮。

检查此链接上的所有播放器属性:https ://developers.google.com/youtube/player_parameters?playerVersion=HTML5

希望这将帮助您始终以全屏模式显示您的 youtube 视频!

于 2019-02-12T13:37:55.883 回答
0

手动设置强制播放playerView.webView.allowsInlineMediaPlayback = falseplayerViewDidBecomeReady进入 webview。

于 2019-02-12T13:11:31.450 回答