Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. Bug Reports
  3. Vimeo embed api / unmute and mute not working - why? any workarounds?

Vimeo embed api / unmute and mute not working - why? any workarounds?

Scheduled Pinned Locked Moved Bug Reports
4 Posts 2 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    T
    Tim B
    wrote on last edited by
    #1

    Hello :)

    after some time I am back posting here with a video embed related question.

    Why is it that this code does not work:

    <div style="padding:61.86% 0 0 0;position:relative;">
        <iframe id="vimeo-player" src="https://player.vimeo.com/video/926876420?autoplay=1&muted=1&badge=0&autopause=0&player_id=0&app_id=58479&controls=0" frameborder="0" allow="autoplay; fullscreen; picture-in-picture; clipboard-write" style="position:absolute;top:0;left:0;width:100%;height:100%;" title="ON — OBSERVING THE SENSATION OF MOVEMENT"></iframe>
    </div>
    <button class="unmute-btn">Unmute Video</button>
    <script src="https://player.vimeo.com/api/player.js"></script>
    <script>
        const player = new Vimeo.Player(document.getElementById('vimeo-player'));
    
        const unmuteBtn = document.querySelector('.unmute-btn');
        unmuteBtn.addEventListener('click', function() {
            player.setMuted(false).then(function() {
                player.setVolume(1);
            }).catch(function(error) {
                console.error('Error unmuting video:', error);
            });
        });
    </script>
    

    In more detail: it is not possible to toggle mute or unmute on vimeo embeds. When using this code in brackets on a normal html it is working.

    I would like to embed videos super clean on autoplay and then click on a simple text element that says "unmute". this should toggle the video to be unmuted and the text to be changed to "mute".

    I already got some good code with codeium but somehow something within Laytheme seems to prevent this from working? Any ideas?

    Would love to make this work.

    cheers :)

    1 Reply Last reply
    0
    • T
      T
      Tim B
      wrote on last edited by
      #2

      This is the rough code that works and that I tested with brackets:

      <!DOCTYPE html>
      <html lang="en">
      <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Vimeo Video with Unmute Button</title>
      <style>
      .unmute-btn {
          cursor: pointer;
          color: blue;
          text-decoration: underline;
      }
      .muted {
          color: red;
      }
      </style>
      </head>
      <body>
      <div style="padding:61.86% 0 0 0;position:relative;">
          <iframe id="vimeo-player" src="https://player.vimeo.com/video/926876420?autoplay=1&muted=1&badge=0&autopause=0&player_id=0&app_id=58479&controls=0" frameborder="0" allow="autoplay; fullscreen; picture-in-picture; clipboard-write" style="position:absolute;top:0;left:0;width:100%;height:100%;" title="ON — OBSERVING THE SENSATION OF MOVEMENT"></iframe>
      </div>
      <div class="unmute-btn">Unmute</div>
      <script src="https://player.vimeo.com/api/player.js"></script>
      <script>
      document.addEventListener('DOMContentLoaded', function() {
          const player = new Vimeo.Player(document.getElementById('vimeo-player'));
          const unmuteBtn = document.querySelector('.unmute-btn');
          let isMuted = true;
      
          unmuteBtn.addEventListener('click', function() {
              if (isMuted) {
                  player.setMuted(false);
                  unmuteBtn.textContent = 'Mute';
                  unmuteBtn.classList.add('muted');
              } else {
                  player.setMuted(true);
                  unmuteBtn.textContent = 'Unmute';
                  unmuteBtn.classList.remove('muted');
              }
              isMuted = !isMuted;
          });
      });
      </script>
      </body>
      </html>
      
      
      1 Reply Last reply
      0
      • arminunruhA
        arminunruhA
        arminunruh
        Global Moderator
        wrote on last edited by arminunruh
        #3

        2 things

        i think the vimeo player.js library might already be included in lay theme, so dont include the <script> tag for it maybe:

        <script src="https://player.vimeo.com/api/player.js"></script>
        

        also instead of this:

        document.addEventListener('DOMContentLoaded', function() {
        

        use:

        window.laytheme.on('newpageshown', function() {
        
        })
        

        for click events read this:
        https://laytheme.com/documentation/custom-javascript.html#binding-click-events

        also when you write javascript and things dont work, you need to debug it by using console.log

        for example:

        const unmuteBtn = document.querySelector('.unmute-btn');
        console.log(unmuteBtn)
        

        in your console you'd then maybe see oh that button couldn't be found

        or after

        unmuteBtn.addEventListener('click', function() {
        

        you could write

        console.log('hi')
        

        and when you click, you'd see in your console: oh there is no "hi", so maybe the click event handler doesn't work or sth like this

        1 Reply Last reply
        0
        • T
          T
          Tim B
          wrote on last edited by Tim B
          #4
          This post is deleted!
          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          Online Users
          Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
          laytheme.com
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Recent
          • Tags
          • Popular
          • Users
          • Search