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

267
Views
Necesito mi página web para reproducir videos aleatorios pero el JS sigue repitiendo el mismo video aleatorio a menos que actualice la página web

La sección HTML realiza un bucle pero reproduce repetidamente el mismo video seleccionado al azar por el JS. Si actualizo el html, reproducirá un video diferente. Me gustaría que elija un video aleatorio diferente después de que expire cada retraso. Me disculpo, soy un poco nuevo en la programación y mi terminología está fuera de lugar.

 //HTML {url:randvideo1, delayms:10000}, //video arrays found in JS var videoArray1 = [ "v/video01.mp4", "v/video02.mp4", "v/video03.mp4", "v/video04.mp4" ]; var randvideo1 = videoArray1[Math.floor(Math.random()*videoArray1.length)];
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Probablemente esté buscando setInterval que llama a una función cada cierto tiempo.

 const delay = 3000; var videoArray1 = [ "v/video01.mp4", "v/video02.mp4", "v/video03.mp4", "v/video04.mp4" ]; function playVideo() { var randvideo1 = videoArray1[Math.floor(Math.random() * videoArray1.length)]; console.log(`Playing video ${randvideo1} for ${delay / 1000} seconds...`) /* The rest of your code to set the new video source in the html. */ } setInterval(playVideo, delay);

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