Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

353
Vistas
Detect via javascript if video is unavailable when using YouTube iframe player

I'm using the YouTube iFrame API to embed YouTube videos on my site. The videos are pulled from Reddit data obtained via their API, so the content dynamically changes. Some of these videos load as "Video Unavailable".

My goal is to detect when this happens, and remove the unavailable video. However, I haven't found a way to detect this state.

What I've tried so far:

  1. Look in the iframe contents for items with a class of ytp-error. This does not work because all modern browsers prevent javascript from looking inside iframe contents.
  2. Adding an onError event listener to the player. This does not work because a video being unavailable apparently does not constitute an error in eyes of the player.

I assume there is some call that I can use to detect this in the player, but I have not found such as call. How can this be detected?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Thankfully, it doesn't require another call to the YT API. In the YouTube iFrame's onReady handler, getPlayerState() will return -1 (unstarted) for "unavailable" videos, while all other videos return a status of 5 (video cued). I can now simply remove all videos from the DOM which have this -1 status.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda