【问题标题】:Youtube API https ProtocolYoutube API https 协议
【发布时间】:2013-07-12 22:00:28
【问题描述】:

当我使用 onYouTubeIframeAPIReady 创建 iframe 播放器 API 时,链接是使用 http 协议创建的

例子:

  // 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');

        tag.src = "https://www.youtube.com/iframe_api";
        var firstScriptTag = document.getElementsByTagName('script')[0];
        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      // 3. This function creates an <iframe> (and YouTube player)
      //    after the API code downloads.
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          width: '560',
          height: '600',
          videoId: '7j8B_r4OfAw',
          events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
          }
        });
      }

iframe 结果:

<iframe id="player" frameborder="0" allowfullscreen="1" title="YouTube video player" width="560" height="600" src="http://www.youtube.com/embed/7j8B_r4OfAw?enablejsapi=1"></iframe>

有人知道如何使用https 协议制作视频吗?需要在平台上安装api。

请,建议!

【问题讨论】:

    标签: http iframe https youtube-api


    【解决方案1】:

    如果您直接在 html 中创建 iframe 元素,则可以指定 https,而不是使用稍后被替换的 div。如果需要,您可以动态创建 iframe 标记。看this section的底部,上面写着怎么做。

    注意——即使您通过 https 加载播放器,实际的视频流也可能通过 http 提供。这似乎在 Chrome 中引起了混合模式警告,尽管其他浏览器没有(根据我去年的经验;它可能已经改变了)。请参阅this official blog post,它解释了可以通过 https 加载播放器,但警告说视频仍然不一定以这种方式提供。

    【讨论】:

      猜你喜欢
      • 2012-11-18
      • 1970-01-01
      • 2014-02-06
      • 2019-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-16
      • 1970-01-01
      相关资源
      最近更新 更多