So, I'm trying to show a Vimeo video only if it exists. I am using the new JavaScript API.
According to their documentation, the event error
should be fired when a video error occurs during loading. I suppose adding the wrong Vimeo video URL should also fire an event error
.
This is what I did to get the event error
in action:
<iframe id="vimeo-player1" src="https://player.vimeo.com/video/13333693532?autoplay=0&background=1" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
Approach 1
player = new Vimeo.Player($('#vimeo-player1'));
player.on('error', function() {
console.log('Error in loading video');
});
Approach 2
player = new Vimeo.Player($('#vimeo-player1'));
player.loadVideo().then(function(id) {
console.log('loaded');
}).catch(function(error) {
console.error(error);
});
None of them work. He never ran an error block.
Additional information (to help you win Bounty):
- Requires a client solution (I do not have access to the server side of the portal)
- Videos are hosted by third-party users.