function playVideo(curr_width, threshold) {
    var video = document.querySelector(".hero__video");
    var videoSources = document.querySelectorAll(".hero__video source");

    if (curr_width > threshold) {
      // add video sources dynamically (if not already loaded)
      if (!loaded) {
        for (var i = 0; i < videoSources.length; i++) {
          videoSources[i].setAttribute(
            "src",
            videoSources[i].getAttribute("data-src"),
          );
        }

        video.load();
        loaded = true;
      }

      video.play();
      video.setAttribute("autoplay", true);
    } else {
      video.removeAttribute("autoplay");
      video.pause();
    }
  }
// indicates if the video sources have been loaded in (we want to do this above the threshold)
indicates if the video sources have been loaded in (we want to do this above the threshold)
indicates if the video sources have been loaded in ( we want to do this above the threshold )
function playVideo(curr_width, threshold) {
    var video = document.querySelector(".hero__video");
    var videoSources = document.querySelectorAll(".hero__video source");
    if (curr_width > threshold) {
      if (!loaded) {
        for (var i = 0; i < videoSources.length; i++) {
          videoSources[i].setAttribute(
            "src",
            videoSources[i].getAttribute("data-src"),
          );
        }
        video.load();
        loaded = true;
      }
      video.play();
      video.setAttribute("autoplay", true);
    } else {
      video.removeAttribute("autoplay");
      video.pause();
    }
  }
function playVideo ( curr_width , threshold ) { var video = document . querySelector ( ".hero__video" ) ; var videoSources = document . querySelectorAll ( ".hero__video source" ) ; if ( curr_width > threshold ) { if ( ! loaded ) { for ( var i = 0 ; i < videoSources . length ; i ++ ) { videoSources [ i ] . setAttribute ( "src" , videoSources [ i ] . getAttribute ( "data-src" ) , ) ; } video . load ( ) ; loaded = true ; } video . play ( ) ; video . setAttribute ( "autoplay" , true ) ; } else { video . removeAttribute ( "autoplay" ) ; video . pause ( ) ; } }
indicates if the video sources have been loaded in (we want to do this above the threshold)
indicates if the video sources have been loaded in ( we want to do this above the threshold )
// add video sources dynamically (if not already loaded)