旋转木马中的视频未显示/正在工作

时间:2017-05-25 04:45:12

标签: twitter-bootstrap youtube carousel

我使用iframe将youtube的视频放置在bootstrap轮播中,但它没有显示且无法正常工作。

<div class="item active">
        <iframe src="https://www.youtube.com/watch?v=NBJ0F1x9d48&list=PL9Dxzvu_wTzMMQ9ip057m5TMJvosVl-N9?autoplay=1">

        

2 个答案:

答案 0 :(得分:1)

带有循环,自动播放和播放列表的iframe

 <iframe src="https://www.youtube.com/embed/DEDS-bSHRfI?controls=1&showinfo=1&rel=0&autoplay=1&loop=1&list=UUcvz3BO8w38d-595tTctOlg&amp;ecver=1" frameborder="0" allowfullscreen></iframe>

<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Carousel Example</h2>  
  <div id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">
      <div class="item active">
        <iframe width="854" height="480" src="https://www.youtube.com/embed/NBJ0F1x9d48?ecver=1" frameborder="0" allowfullscreen style="width:100%;"></iframe>
      </div>

      <div class="item">
        <img src="http://vivera.ae/image/slider/heathbay2.JPG" alt="Chicago" style="width:100%;">
      </div>
    
      <div class="item">
        <img src="http://vivera.ae/image/slider/bmc.jpg" alt="New york" style="width:100%;">
      </div>
    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
</div>

</body>
</html>

从youtube复制嵌入代码。使用此iframe

<iframe width="854" height="480" src="https://www.youtube.com/embed/NBJ0F1x9d48?ecver=1" frameborder="0" allowfullscreen></iframe>

答案 1 :(得分:0)

试试这个。

<div class="container"> <div class="span8">
<div id="myCarousel" class="carousel slide">
    <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class=""></li>
        <li data-target="#myCarousel" data-slide-to="1" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="2" class=""></li>
    </ol>
    <div class="carousel-inner">
        <div class="item active">
            <iframe src="//www.youtube.com/embed/-w-58hQ9dLk?controls=0" allowfullscreen="" width="100%" height="100%" frameborder="0"></iframe>
        </div>
        <div class="item">
            <iframe src="//www.youtube.com/embed/SEBLt6Kd9EY?controls=0" allowfullscreen="" width="100%" height="100%" frameborder="0"></iframe>
        </div>
        <div class="item">
            <iframe src="//www.youtube.com/embed/IkTw7J-hGmg?controls=0" allowfullscreen="" width="100%" height="100%" frameborder="0"></iframe>
        </div>
    </div>
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
</div>
</div>

希望这会有所帮助