2016-09-15 3 views
0

사용자가 비디오를 되 감아 비디오 옆에있는 텍스트를 바꿀 때도 원하지만이 코드를 설정하려면 먼저 시작해야합니다. 인터넷에서이 코드를 채우고 실제로 사용하지 않습니다. 왜이 코드가 작동하지 않는지 알지 못합니다.jQuery 및 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> 

누군가가이 문제를 해결하는 방법을 알고 있다면 기쁜 데 도움이됩니다.

답변

0

위의 코드는 Vimeo 비디오에서 발생하는 이벤트에 대한 핸들러를 설정합니다. 사용해야하는 이벤트는 'seekTo'입니다. 따라서 다른 플레이어와 마찬가지로 이벤트를 추가하고 현재 재생 시간이 seekTo 재생 시간보다 작 으면 되감기를 감지했습니다.

그리고 되감기 논리 내부에서 텍스트를 조작 할 수 있습니다.