How do to listen on ended event even when URL is changed?
when the page loads then the player.on ended works, but when i change the url then the ended event doesn't work?
How do i fix this?
<script src="https://player.vimeo.com/api/player.js"></script>
<div class="embed-responsive embed-responsive-16by9">
<iframe src="https://player.vimeo.com/video/137857207" name="frame1" id="frame1" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
<a href="https://player.vimeo.com/video/137857207" onclick="return loadIframe(this.href);">Page 1</a>
<a href="https://player.vimeo.com/video/344456217?h=e78b006de0" onclick="return loadIframe(this.href);">Page 2</a>
<script>
function loadIframe(url) {
$("#frame1").attr('src',url);
return false;
}
</script>
<script>
var iframe = document.getElementById('frame1');
var player = new Vimeo.Player(iframe);
player.on('play', function() {
// alert('You have played the video')
});
player.on('ended', function(){
<?php
echo "alert('Video play completed')";
?>
});
player.getVideoTitle().then(function(title) {
console.log('title:', title);
});
</script>