Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda