'mutate / unmute vimeo video
I am trying to change the muted attribute on a Vimeo video within an iframe.
The video starts automatically and is silent, when you click on it the overpressed images are hidden and the video restarts with the audio.
My HTML code is this:
<div class="elVideo">
<div class="fluid-width-video-wrapper" style="">
<iframe class="iframeClass" allow="autoplay" src="https://player.vimeo.com/video/659246147?h=0926a4535b&title=0&byline=0&portrait=0&transparent=0&autoplay=1&loop=0&autopause=0&muted=1" frameborder="0" allowfullscreen=""></iframe>
</div>
<div class="iframeBlocker">
<div class="video-sound-overlay"></div>
</div>
</div>
My script is this:
<script>
$(".elVideo").one("click", function () {
var options = {
url: "https://player.vimeo.com/video/659246147?h=0926a4535b&title=0&byline=0&portrait=0&transparent=0&autoplay=1&loop=0&autopause=0&muted=0"};
var videoElement = document.getElementsByClassName('elVideo')[0];
var videoplay = document.getElementsByClassName('video-sound-overlay')[0];
var videoiFrame = videoElement.querySelector('iframe');
var player = new Vimeo.Player(videoiFrame , options);
player.setMuted(0);
player.setCurrentTime(0);
player.setVolume(1);
player.play();
videoElement.classList.add('removedSoundOn');
videoplay.classList.add('removedSoundOn');
});
</script>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
