簡體   English   中英

jQuery和Vimeo Froogaloop2 API onPlayProgress

[英]jQuery and Vimeo Froogaloop2 API onPlayProgress

我想在用戶倒帶視頻時在視頻一邊更改文本,但現在我要首先開始設置此代碼。我在互聯網上找到了該代碼,但我真的不知道為什么該代碼不起作用。

<!DOCTYPE html>
<html>
<head>
    <title> </title>

</head>
<body>

<iframe id="player1" src="https://player.vimeo.com/video/76979871?api=1&player_id=player1" width="630" height="354" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

<div>
  <button>Play</button>
  <button>Pause</button>
  <p>Status: <span class="status">&hellip;</span></p>
</div>


   <script src="https://f.vimeocdn.com/js/froogaloop2.min.js"></script>
   <script> $(function() {
    var iframe = $('#player1')[0];
    var player = $f(iframe);
    var status = $('.status');

    // When the player is ready, add listeners for pause, finish, and playProgress
    player.addEvent('ready', function() {
        status.text('ready');

        player.addEvent('pause', onPause);
        player.addEvent('finish', onFinish);
        player.addEvent('playProgress', onPlayProgress);
    });

    // Call the API when a button is pressed
    $('button').bind('click', function() {
        player.api($(this).text().toLowerCase());
    });

    function onPause() {
        status.text('paused');
    }

    function onFinish() {
        status.text('finished');
    }

    function onPlayProgress(data) {
        status.text(data.seconds + 's played');
    }
});
</script>
</body>
</html>

因此,如果有人知道如何解決此問題,請幫忙!

上面的代碼幾乎為Vimeo視頻中發生的事件設置了處理程序。 您需要使用的事件是“ seekTo”。 因此,您將像添加其他事件一樣添加一個事件,並且如果當前播放時間小於seekTo播放時間,我們知道我們已經檢測到倒帶。

在倒帶邏輯的內部,我們可以在側面操作文本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM