Отслеживание% просматриваемого видео не работает (timeupdate & vimeo). Почему? - PullRequest
1 голос
/ 26 октября 2019

Немного погуглив, я пришел к следующему коду для отслеживания воспроизведения, завершения и прогресса видео (% просмотренного видео). Я использовал Vimeo API Tracking для ввода.

PLAY и END работа. TIMEUPDATE работает также, но не console.log, когда просматривается 10% видео. Я не могу понять, что я делаю неправильно.

<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>video-test-vimeo</title>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>

<iframe src="https://player.vimeo.com/video/76979871" width="640" height="360" frameborder="0" allowfullscreen allow="autoplay; encrypted-media"></iframe>

<script src="https://player.vimeo.com/api/player.js"></script>
<script>
    var iframe = document.querySelector('iframe');
    var player = new Vimeo.Player(iframe);

    player.on('play', function() {
        console.log('played the video!');
    });
	
	player.on('ended', function() {
        console.log('ended the video!');
    });
	
	player.on('timeupdate', function(data) {
		console.log('Percentage watched: '+data.percent);
    	if (data.percent == 0.1) {
			console.log('10% of video watched');
     	}
 });
</script>
</body>
</html>
...