I am using the iOS YouTube Player helper (https://developers.google.com/youtube/v3/guides/ios_youtube_helper) and it works just fine but the preview image is not the size of
A bit late to the party, but since none of the other solutions worked for me, I solved it by constraining the webView / YTPlayerView to a 16:9 aspect ratio as that is the standard aspect ratio for YouTube videos according to this:
https://support.google.com/youtube/answer/6375112?co=GENIE.Platform%3DDesktop&hl=en
With your webView/playerView the same aspect ratio as the video, the preview image will display properly.
This solved it for me:
In the Assets folder there should be an html file named "YTPlayerView-iframe-player.html"
Replace the existing code between "style" tags as shown below and this will make sure the Player fills 100% of the YTPlayerView:
<style>
body { margin: 0; width:100%%; height:100%%; }
html { width:100%%; height:100%%; }
</style>
Hope this helps a bit! Have a great weekend!
I find another solution. If you use YTPlayerView in a xib file, please make sure the following points.
1, Check 'Use Auto Layout'
2, DO NOT set the width and height value for YTPlayerView.
then the YTPlayerView will play normally.
You can reset webView size in the following method:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
//
self.player.webView.bounds = CGRectMake(0, 0, self.player.bounds.size.width, self.player.bounds.size.height*1.5);
[self.player.webView setNeedsDisplay];
}