Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Cómo reproducir automáticamente cualquier video iframe si está en la ventana gráfica

Hay desarrolladores. De hecho, tengo un pequeño problema. Estoy tratando de hacer cosas como si el iframe estuviera en la ventana gráfica, entonces el video se reproducirá automáticamente.

Condición

  1. Iframe está en la ventana gráfica, luego se reproducirá el video
  2. El video iframe se detiene si no está en la ventana gráfica
  3. El video iframe se detiene si se abre algún modal

 function playvideo(iframe) { iframe.contentWindow.postMessage( '{"event":"command","func":"playVideo","args":""}', '*' ) } function pausevideo(iframe) { iframe.contentWindow.postMessage( '{"event":"command","func":"pauseVideo","args":""}', '*' ) } let observeroptions = { root: null, rootMargin: '0px', threshold: 1.0 }; let callback = (entries, observer) => { entries.forEach((entry) => { if (entry.isIntersecting) { playvideo(entry.target) } else { // pausevideo(entry.target); observer.unobserve(entry.target) } }) } let observer = new IntersectionObserver(callback, observeroptions); $(window).scroll(function () { $('iframe').each(function (e) { if ($(this).isInViewport()) { observer.observe($(this)[0]) } }) })
Este es el enlace de mi sitio web

https://letscodeon.me/research.php?category=videos

Problema El problema es que el video se detiene cuando la página se vuelve a cargar, no se reproduce automáticamente cuando está en la ventana gráfica. Si reproduzco un video, la reproducción automática funciona.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!