title: Is there a way to verify if a livestreamed image is available to load before displaying it?
body: <p>I made a very simple project a while ago that consists of two videos (that come from a security camera array which is livestreamed) that are randomly chosen and displayed for 1 minute only. After 1 minute is up, the page's refreshed and a new set of two videos show up. But the problem is: some security cameras aren't available all the time because of server issues, so once in a while what happens is that 2 videos are randomized and one (or both of them) aren't displayed, so I was wondering is there a way to code this?</p>
  <p>For some reason I was only able to code the array of security cameras as images, not as videos.</p>
  <p>Here's the code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>document.addEventListener("DOMContentLoaded", function(event) {
      var myPix = new Array("http://180.23.155.164:8082/-wvhttp-01-/GetOneShot?&amp;frame_count=1000000000#.XuE-YLJZhYI.link",
        "http://180.220.70.194:1024/-wvhttp-01-/GetOneShot?&amp;frame_count=1000000000#.XujHZZ-5jOU.link",
        "http://107.85.194.33:8081/-wvhttp-01-/GetOneShot?&amp;frame_count=1000000000#.XujTCpm4q4M.link");
      //the list is very long so i'll stop here
      function choosePic() {
        var randomNum = Math.round(Math.random() * myPix.length);
        var randomNum2;
        // Keep generating randomNum2 if randomNum equals randomNum2
        do {
          randomNum2 = Math.round(Math.random() * myPix.length)
        } while (randomNum === randomNum2);
        document.getElementById("myPicture").src = myPix[randomNum];
        document.getElementById("myPicture2").src = myPix[randomNum2];
      }
      // First loading of camera resources
      choosePic();
    )
  };</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section class="hero is-fullheight has-background-black"&gt;
    &lt;div class="hero-body"&gt;
      &lt;div class="container"&gt;
        &lt;figure class="center"&gt;
          &lt;img width="512px" height="384px" id="myPicture"&gt;
          &lt;img width="512px" height="384px" id="myPicture2"&gt;
        &lt;/figure&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I'm coder beginner, so I don't know if this is something silly which I'm foreseeing or not.</p>