【问题标题】:Youtube video api video not showing upYoutube 视频 api 视频未显示
【发布时间】:2017-03-23 19:53:57
【问题描述】:

大家好,我正在使用 youtube 视频背景 api,并且想在我的页面中在我已经设置的 div 的背景上设置一个视频,所以我有这个 html:

<div class="embed-responsive embed-responsive-16by9" id="video">

</div>

javascript

$(document).ready(function () {
    $('#video').YTPlayer({
        fitToBackground: true,
        videoId: 'LSmgKRx5pBo',
        playerVars: {
            modestbranding: 0,
            autoplay: 1,
            controls: 1,
            showinfo: 0,
            branding: 0,
            rel: 0,
            autohide: 0,
            start: 10
        }
    });
})

这是我使用 api 的link,我没有收到任何控制台错误,我做错了什么??

【问题讨论】:

    标签: javascript jquery video youtube


    【解决方案1】:

    Here 是一个工作小提琴,带有一些文本和视频上方的按钮:

    $(document).ready(function() {
      $('#video').YTPlayer({
        fitToBackground: true,
        videoId: 'LSmgKRx5pBo',
        playerVars: {
          modestbranding: 0,
          autoplay: 1,
          controls: 1,
          showinfo: 0,
          branding: 0,
          rel: 0,
          autohide: 0,
          start: 10
        }
      });
    })
    #video {
      position: relative;
      background: transparent;
    }
    
    .ytplayer-container {
      position: absolute;
      top: 0;
      z-index: -1;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://cdn.rawgit.com/rochestb/jQuery.YoutubeBackground/dbdfa723/src/jquery.youtubebackground.js"></script>
    <div class="embed-responsive embed-responsive-16by9" id="video">
      <p>Some text</p>
      <input type="submit" value="some button" />
    </div>

    【讨论】:

      猜你喜欢
      • 2016-10-15
      • 2015-11-03
      • 2019-08-07
      • 2015-10-01
      • 2014-07-15
      • 1970-01-01
      • 2011-11-07
      • 2016-07-28
      • 2016-05-22
      相关资源
      最近更新 更多