Reputation: 1833
I want to play YouTube video in specific view size. currently I'm unable to play video in full view size.
You can check the below image where black part is displaying in both left and right side.
Upvotes: 0
Views: 1578
Reputation: 35372
First of all, you should set your custom YTPlayerView
with content mode equal to "scale to fill". Next, you should set the playsinline
property to 0.
Here below I show you a little example:
var playerVars:Dictionary =
["playsinline":"0", // 1 in view or 0 fullscreen
"autoplay":"1", // Auto-play the video on load
"modestbranding":"1", // without button of youtube and giat branding
"rel":"0",
"controls":"0", // Show pause/play buttons in player
"fs":"1", // Hide the full screen button
"origin":"https://www.example.com",
"cc_load_policy":"0", // Hide closed captions
"iv_load_policy":"3", // Hide the Video Annotations
"loop":"0",
"version":"3",
"playlist":"",
"autohide":"0", // Hide video controls when playing
"showinfo":"0"] // show related videos at the end
self.playerView.load(withVideoId: videoId, playerVars: playerVars)
Remember if you want a good resolution inside your view using a 16:9 view when you try to play a 4:3 video you have always black side parts and this behaviour is correct and reasonable.
If you want more specific details about your request you can find interesting information in this page (a page related to the official gitHub Youtube sources)
Upvotes: 1