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

232
Vistas
Using the youtube-iframe-api, the playVideo() method does start the video in Chrome (works in Safari and FF)

Problem can be seen here: https://www.wgbh.org/news/local-news/2022/06/07/housing-is-in-short-supply-heres-why-that-matters

When clicking on the poster image play button, the poster image disappears and the video should start playing (triggered by <player>.playVideo() from the API).

However, in Chrome (and in Brave), the user must also click the YT native play button. No errors are shown from the playVideo() method.

The user click triggers the play() function in this code snippet (not live), I call playVideo() every half second. The initial video state is "video cued" but after that, the state never changes from "unstarted" and the video never plays.

     play () {
        console.log('Received play signal from poster')
        let playerState = this.player.getPlayerState().toString()
        const thePlayer = this.player
        console.log('Pre-play-signal state: ', PLAYER_STATES[playerState])
        let waitForPlay = setInterval(function () {
          thePlayer.playVideo()
          playerState = thePlayer.getPlayerState().toString()
          console.log('Interval play state: ', PLAYER_STATES[playerState])
          if (playerState === '1') {
            clearInterval(waitForPlay)
            console.log('Final play state: ', PLAYER_STATES[playerState])
          }
        }, 500)
      }

Response headers from the playVideo() requests:

accept-ranges: bytes
access-control-allow-credentials: true
access-control-allow-origin: https://www.youtube.com
access-control-expose-headers: Client-Protocol, Content-Length, Content-Type, X-Bandwidth-Est, X-Bandwidth-Est2, X-Bandwidth-Est3, X-Bandwidth-App-Limited, X-Bandwidth-Est-App-Limited, X-Bandwidth-Est-Comp, X-Bandwidth-Avg, X-Head-Time-Millis, X-Head-Time-Sec, X-Head-Seqnum, X-Response-Itag, X-Restrict-Formats-Hint, X-Sequence-Num, X-Segment-Lmt, X-Walltime-Ms
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
cache-control: private, max-age=21248
client-protocol: quic
content-length: 2097152
content-type: video/webm
cross-origin-resource-policy: cross-origin
date: Wed, 08 Jun 2022 20:19:21 GMT
expires: Wed, 08 Jun 2022 20:19:21 GMT
last-modified: Tue, 07 Jun 2022 13:41:59 GMT
server: gvs 1.0
timing-allow-origin: https://www.youtube.com
vary: Origin
x-content-type-options: nosniff
x-restrict-formats-hint: None

I have tried this a browser opened with the --disable-web-security flag, but no difference.

Any help would be appreciated. Thanks.

about 4 years ago · Juan Pablo Isaza
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