1

In the snippet, I have a Wistia embedded video loading via lazyload. With autoPlay=true, I'm unable to have the video unmuted when it starts playing.

muted=false doesn't seem to work as described in the docs here.

Any ideas on how to have it unmuted while autoPlay is true?

(function () {
  const wistia = document.querySelectorAll(".wistia");

  for (let i = 0; i < wistia.length; i++) {
    let source = `https://embed-ssl.wistia.com/deliveries/${wistia[i].dataset.thumb}.jpg`

    let image = new Image();
    image.src = source;
    image.addEventListener("load", (function () {
        wistia[i].appendChild(image);
      })(i)
    );

    wistia[i].addEventListener("click", function () {
      let iframe = document.createElement("iframe");

      iframe.setAttribute("frameborder", "0");
      iframe.setAttribute("allowfullscreen", "");
      iframe.setAttribute("mozallowfullscreen", "");
      iframe.setAttribute("webkitallowfullscreen", "");
      iframe.setAttribute("oallowfullscreen", "");
      iframe.setAttribute("msallowfullscreen", "");
      iframe.setAttribute('src', `//fast.wistia.net/embed/iframe/${this.dataset.embed}?videoFoam=true&autoPlay=true`);

      this.innerHTML = "";
      this.appendChild(iframe);
    });
  }
})();
.wistia {
    background-color: #000;
    margin-bottom: 30px;
    position: relative;
    padding-top: 56.25%;
    overflow: hidden;
    cursor: pointer;
}
.wistia img {
    width: 100%;
    top: 0; /* Change this for different ratio than 16:9 */
    left: 0;
    // opacity: 0.7;
}
.wistia .play-button {
    width: 90px;
    height: 60px;
    background-color: #333;
    // box-shadow: 0 0 30px rgba( 0,0,0,0.6 );
    z-index: 1;
    // opacity: 0.8;
    border-radius: 6px;
}
.wistia .play-button:before {
    content: "";
    border-style: solid;
    border-width: 15px 0 15px 26.0px;
    border-color: transparent transparent transparent #fff;
}
.wistia img,
.wistia .play-button {
    cursor: pointer;
}
.wistia img,
.wistia iframe,
.wistia .play-button,
.wistia .play-button:before {
    position: absolute;
}
.wistia .play-button,
.wistia .play-button:before {
    top: 50%;
    left: 50%;
    transform: translate3d( -50%, -50%, 0 );
}
.wistia iframe {
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
}
<div class="wistia" data-embed="fousa0gqve" data-thumb="772ba38639a8dd752968933b95e3a7282f4d6a7b">
    <div class="play-button"></div>
</div>
Millhorn
  • 2,953
  • 7
  • 39
  • 77

0 Answers0