2017-01-09 191 views
1

我在同一頁面上有多個視頻。但是 - 我可以同時播放多個視頻並聽取每個視頻。當我開始另一個視頻時 - 正在播放的視頻必須關閉。JW Player停止播放多個視頻

<div class="tab-pane active" id="abc"><div class="panel-body"> 
    <script src="//content.jwplatform.com/players/abc.js"></script></div> 
</div> 
<div class="tab-pane" id="def"><div class="panel-body"> 
    <script src="//content.jwplatform.com/players/def.js"></script></div> 
</div> 
<div class="tab-pane" id="ghi"><div class="panel-body"> 
<script src="//content.jwplatform.com/players/ghi.js"></script></div> 
</div> 
<div class="tab-pane" id="jkl"><div class="panel-body"> 
    <script src="//content.jwplatform.com/players/jkl.js"></script> </div> 
</div> 

回答

1

這是你的HTML是什麼樣子:

<div id='player1'></div> 
    <div id='player2'></div> 
    <div id='player3'></div> 

這裏是你的JS應該做的。密切關注onPlay事件:

jwplayer("player1").setup({ 
    playlist: [{ 
    file: "bbb_sunflower_1080p_60fps_normal.mp4" 
    }], 
     width: 300, 
     aspectratio: '16:9', 
     events: { 
      onPlay: function() { 
      jwplayer('player2').stop();jwplayer('player3').stop(); 
      }, 
      onComplete: function() { 
      //something can happen at the end of the video here if you'd like. 
      } 
     }, 
     }); 
//etc. 

演示:http://codepen.io/simsketch/pen/LxpmWx

希望這有助於!

0

JW球員有這樣的代碼示例:

https://developer.jwplayer.com/jw-player/demos/basic/mutually-exclusive/

你的設置似乎不過關,你不應該有多個玩家庫,所以很有可能你有多個單行嵌入這也是不是最好的事情。我建議使用類似於上面的文檔中描述的一個代碼,你有一個雲中託管的球員,並呼籲

jwplayer('DIV_ID').setup(); 

每個球員。