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

191
Vistas
Videos do not display in Safari – unless they are played (Javascript)

I am building STEEP. We are using infinite scroll to load in 8 videos at a time when scrolling the page. We do not want to use the 'poster' attribute, so we have created a script that uses a specific frame from the video to display as the poster – by extracting a timestamp (i.e. #t=2) from our source URL.

Everything works as intended in Chrome – however, in Safari, the videos are not visible at all, unless they have played at least once i.e. by running video.play().

Would love some input on why the videos might not display in Safari – or some smart ideas for a workaround that could fix it.

SCRIPT:

const list = document.querySelector('.collection-list');

const isVideoPlaying = video => !!(
  video && !video.paused && !video.ended && video.readyState > 2
);

function playVideo(el) 
{
    if(!isVideoPlaying(el))
  {
    var posterTime = el.currentTime;
    var videoDuration = el.duration; 
    el.currentTime = 0;
    el.play();
    $('.progress-bar').css('animation', 'reset linear 0s');
    $('.progress-bar').css('animation', 'move linear ' + videoDuration + 's infinite');
    }
}

function pauseVideo(el) 
{
    if(isVideoPlaying(el))
  { 
    let src = el.querySelector('source').src;
    let time = (src.split('#')[1] || 't=0').split('=')[1];
    el.currentTime = time;
    el.pause();

    $('.progress-bar').css('animation', 'reset linear 0s');
    }
}

const updateVideos = () => {
  [...document.querySelectorAll('.collection-list video:hover')]
    .forEach(playVideo);
  [...document.querySelectorAll('.collection-list video:not(:hover)')]
    .forEach(pauseVideo);
}

list.addEventListener('mouseover', updateVideos);
list.addEventListener('mouseout', updateVideos);

HTML:

<video id="video" width="100%" height="auto" loop muted playsinline preload="auto">
  <source src="CMS VIDEO URL HERE">
</video>

Note: We are not very experienced with javascript and use Webflow combined with some custom code.

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