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

194
Views
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
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!