View Size for YTPlayer

后端 未结 4 1367
挽巷
挽巷 2021-01-03 09:29

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

相关标签:
4条回答
  • 2021-01-03 09:34

    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.

    0 讨论(0)
  • 2021-01-03 09:40

    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!

    0 讨论(0)
  • 2021-01-03 09:48

    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.

    0 讨论(0)
  • 2021-01-03 09:49

    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];
    }
    
    0 讨论(0)
提交回复
热议问题