如何强制youtube播放高清视频 [英] How to force youtube to play HD videos

查看:219
本文介绍了如何强制youtube播放高清视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下视频在框架中,强烈希望一开始就以高品质运行它。

https://www.youtube.com/embed/3nmnMtbzzjE

我试过参数如hd = 1和vq = hd720, vq = hd1080但我认为这些已经过时或不在功能。



请建议。
Regards

解决方案

我刚刚解决了这个问题,因为我正在处理一个网站。 b

我嵌入了带有YouTube视频的内置iframe,尽管我想让它们以720p自动播放,但它们仍然以低分辨率自动播放。这个问题是由视频的实际大小造成的,您的网页上会被YouTube检测到,这会触发自动选择较低分辨率的内容。



以下是我为了保持我的视频嵌入小,但它有自动播放720p等 -


  1. 您需要在最后添加?vq = hd720您的视频ID,因为您已完成。

  2. 手动将iframe宽度设置为width =1280height =720 - 这将使您的网站上的视频变得庞大。 li>
  3. 将iframe包装到一个div中,并给它一个类选择器,以便您可以使用css来设计它。

  4. 使用CSS来告诉div包装器是大小,你真的想要的视频。

  5. 使用CSS来设置iframe宽度:100%和高度:100%。
    $ b

    此代码基本上将视频大小设置为您希望自动播放的分辨率,这将诱使YouTube为您设置此分辨率。然后CSS动态地调整视频的大小,使其成为您需要的任何实际大小。



    这就是它的全部内容:)

    代码示例:

    HTML

     < div class =youtube-embed> 
    < iframe width =1280height =720src =https://www.youtube.com/embed/VIDEOID?vq=hd720frameborder =0allowfullscreen>< / iframe>
    < / div>

    CSS

      .youtube-embed {
    width:740px;
    height:400px;
    }

    .youtube-embed iframe {
    width:100%;
    身高:100%;
    }


    I have below video in frame and forcefully wants to run it on High Quality at first go

    https://www.youtube.com/embed/3nmnMtbzzjE

    I tried Parameters like hd=1 and vq=hd720 and vq=hd1080 But i think these are outdated or not in function.

    Please suggest. Regards

    解决方案

    I just solved this problem for a website I was working on.

    I have embedded iframes with youtube videos in them and they, annoyingly, auto-played at a low resolution despite my wanting them to auto-play at 720p. This issue is caused by the actual size of the video, on your page, being detected by YouTube which will trigger an auto-selection of a lower res.

    Here's what I did to keep my video embed small, but have it auto play on 720p etc -

    1. You need to add ?vq=hd720 at the end of your video id, as you have done.
    2. Manually set the iframe width to width="1280" height="720" - which will make the video huge on your site.
    3. Wrap the iframe in a div and give it a class selector so you can style it with css.
    4. Use CSS to tell your div wrapper to be the size you actually want the video to be.
    5. Use CSS to set the iframe width:100% and height:100%.

    This code will basically set the video size to be that of the resolution you want it to auto-play on, which will trick YouTube into setting this for you. Then the CSS dynamically resizes the video to be whatever actual size you need.

    And that's all there is to it :)

    CODE EXAMPLE:

    HTML

    <div class="youtube-embed">
        <iframe width="1280" height="720" src="https://www.youtube.com/embed/VIDEOID?vq=hd720" frameborder="0" allowfullscreen></iframe>
    </div>
    

    CSS

    .youtube-embed {
        width  : 740px;
        height : 400px;
    }
    
    .youtube-embed iframe {
        width  : 100%;
        height : 100%;
    }
    

    这篇关于如何强制youtube播放高清视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆