jeudi 24 mai 2018

Find values in array depending on a pattern in Javascript

I have an array:

var videoSources = 
["0000.mp4", 
"0015.mp4", 
"0030.mp4", 
"0045.mp4", 
"0100.mp4"]

I would play videos based on current time; mp4 are recorded every 15minutes;

if time = 0044 play 0030.mp4

So I need something like a pattern [0-15] to find and play correct video. Here function to play video at the moment:

    var currentIndex = 0;
// listener function changes src
      function myNewSrc() {
          var myVideo = document.getElementsByTagName('video')[0];
          myVideo.src = videoSources[currentIndex];
          myVideo.load();
      }

Aucun commentaire:

Enregistrer un commentaire