How to get YouTube video aspect ratio

前端 未结 6 1366
滥情空心
滥情空心 2020-12-14 20:16

I\'d like to get the aspect ratio of a YouTube video, to resize the player accordingly. I\'m programming the YT player using JavaScript.

6条回答
  •  爱一瞬间的悲伤
    2020-12-14 21:03

    Aspect ratio apparently depends on the quality level. Taken from the YouTube Docs:

    Quality level small: Player height is 240px, and player dimensions are at least 320px by 240px for 4:3 aspect ratio.
    Quality level medium: Player height is 360px, and player dimensions are 640px by 360px (for 16:9 aspect ratio) or 480px by 360px (for 4:3 aspect ratio).
    Quality level large: Player height is 480px, and player dimensions are 853px by 480px (for 16:9 aspect ratio) or 640px by 480px (for 4:3 aspect ratio).
    Quality level hd720: Player height is 720px, and player dimensions are 1280px by 720px (for 16:9 aspect ratio) or 960px by 720px (for 4:3 aspect ratio).
    Quality level hd1080: Player height is 1080px, and player dimensions are 1920px by 1080px (for 16:9 aspect ratio) or 1440px by 1080px (for 4:3 aspect ratio).
    Quality level highres: Player height is greater than 1080px, which means that the player's aspect ratio is greater than 1920px by 1080px.
    

提交回复
热议问题