php 最佳 Youtube 嵌入播放器尺寸?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2618020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best Youtube embed player sizes?
提问by Xeoncross
I use tumblr to share videos and, unfortunately, when re-posting a video to your tumblelog it uses the embed code at 400x336px. This is neither widescreen nor very large.
我使用 tumblr 来分享视频,不幸的是,当将视频重新发布到您的 tumblelog 时,它使用了 400x336px 的嵌入代码。这既不是宽屏也不是很大。
So I'm trying to set the player to better size and I'm finding that the youtube player really comes in many sizes. For example, when copying the embed code for and HD video I get the sizes 560x340, 640x385, and 853x505. Then when I look at the embed code for a SD video I get the sizes 425x344, 480x385, and 640x505.
所以我试图将播放器设置为更好的尺寸,我发现 youtube 播放器确实有多种尺寸。例如,在复制 HD 视频的嵌入代码时,我得到的大小为560x340、640x385 和 853x505。然后,当我查看 SD 视频的嵌入代码时,我得到了425x344、480x385 和 640x505的大小。
I was having the best luck with setting the player to 640 x 505 as it was large enough for HD and perfect for SD.
我很幸运地将播放器设置为 640 x 505,因为它对于高清来说足够大,对于标清来说是完美的。
print str_replace( array('400', '336'), array('640', '505'), $video_player_html);
Has anyone dealt with trying to find a good standard embed size for a site? One thing that would make this a lot easier is to know whether the video was HD or not - however, that info is not provided in the embed code.
有没有人试图为网站找到一个好的标准嵌入尺寸?使这更容易的一件事是知道视频是否为高清 - 但是,嵌入代码中未提供该信息。
I guess I am actually more interested in knowing the right ratio (or specific size) to use that works the best for youtube's mixed content.
我想我实际上更感兴趣的是知道正确的比例(或特定大小)使用它最适合 youtube 的混合内容。
Update
更新
Since HD seems to be .5625 ratio (16/9) I'm thinking that I can just decide on a hight and multiply it by the ratio to get the proper width each time (plus 23px for youtube bar).
由于高清似乎是 0.5625 比率(16/9),我想我可以决定一个高度并将其乘以比率以获得每次正确的宽度(加上 23px 的 youtube 栏)。
采纳答案by Syntax Error
You don't have to worry about the sizes youtube offers. When you copy the embed code, paste it into a text editor and you'll see it contains width and height parameters in two places. You can change those values to anything at all and the player will resize. So grab your JRuler, figure out what size would be ideal for your tumblelog, and just edit the player code each time.
您不必担心 youtube 提供的尺寸。当您复制嵌入代码时,将其粘贴到文本编辑器中,您将看到它在两个位置包含宽度和高度参数。您可以将这些值更改为任何值,播放器将调整大小。因此,拿起您的JRuler,找出最适合您的 tumblelog 的大小,然后每次只需编辑播放器代码。
It's kind of a pain, but it gets you the result you want.
这有点痛苦,但它会让你得到你想要的结果。

