How to catch the 404 error from Vimeo player.js when no video is found

591 Views Asked by At

A react component that uses the Vimeo Player. Does anyone know how to catch the 404 error that the player throws in the console? seems that Vimeo has no api/event to handle those events during initiation? Would like to show an alternative screen if the video is not found.

let player = new Vimeo.default(videoPlayerContainer.current, {
        url: videoUrl,
        controls: true,
        responsive: true,
        transparent:false,
        dnt:true, 
        color: '327ea5'
      })

Searchd all documentation but cant seem to find anything. My guess is that the error is thrown from inside the iframe vimeo creates but there is no way of handling it.

1

There are 1 best solutions below

0
MrJgaspa On

Try catching the rejected promise in the catch hook:

let player = new Vimeo.default(videoPlayerContainer.current, {
  url: videoUrl,
  controls: true,
  responsive: true,
  transparent: false,
  dnt: true,
  color: "327ea5",
}).catch(err => {
  // handle error here
  console.warn(err);
});