0

See this link: http://jitimanagementcoach.com/TC_test/tabbed4try.html I've already got the videos to play and/or pause on one tab or another when a tab is clicked... but now I need the video on the Prelearn tab to "click" the Solution tab and play the video once the Prelearn video is finished. Here's the code:

               <script>
var iframe1 = document.getElementById("prelearnvid");
var iframe2 = document.getElementById("solutionvid");
var player1 = $f(iframe1);
var player2 = $f(iframe2);
var prelearnBtn = document.getElementById("prelearnbtn");
prelearnBtn.addEventListener("click", function() {player1.api("play");player2.api("pause");});

var solutionBtn = document.getElementById("solutionbtn");
solutionBtn.addEventListener("click", function() {player2.api("play");player1.api("pause");});

    player1.addEvent('ready', function() {player1.addEvent('finish', onFinish);});

    function onFinish(id) {window.location.href = '#solution-tab';};

        </script>

It all works fine until the very last two lines... where am I going wrong?

4

1 回答 1

0

ready事件不会为您的播放器触发。为了让播放器的事件触发,您需要向player_id您的 URL 添加一个参数,其中id包括<iframe>.

src将您的属性更改为<iframe>

<iframe id="prelearnvid" src="http://player.vimeo.com/video/92349330?&amp;player_id=prelearnvid"

Froogaloop 文档

如果您在一个页面上嵌入和控制多个播放器或使用我们的 JS API 库 (Froogaloop),您应该为每个播放器提供一个 player_id与 iframe 元素的 id 匹配的值。

这个stackoverflow 答案和这个论坛帖子帮助发现了这个解决方案。

于 2015-01-30T03:32:00.447 回答