Back to the Shapespark home page

Adding Buttons?

According to https://stackoverflow.com/a/25781957 you also need to include playlist=<VIDEO-ID>.

As for the sound playing even after the video is closed, there was a typo in my script: you have to replace innerHtml with innerHTML.

I’ve edited my previous post to include these two changes.

Hey,

I’m trying to implement this code but is not working :thinking: what am I missing

Do you mean the button doesn’t show up, or the video doesn’t play?

Button is not showing up

Could you share a link to the scene, so we could take a look at it?

This is the link: https://meet.kazooie.io/ventusst/

This is my code:

<script>

  const viewer = WALK.getViewer();

  viewer.onSceneReadyToDisplay(function() {

    const button = viewer.addMenuButton('<https://icons.kazooie.io/shopping_cart.svg>');

    const container = document.getElementById('ext-html-label');

    const content = document.getElementById('ext-html-label-content');

    const close = document.getElementById('ext-html-label-close');

    button.onclick = function() {

      container.style.display = '';

      container.dataset.id = 'menu-button';

      content.innerHTML = '<iframe width="560" height="315" src="https://www.youtube.com/embed/u2hYn_4yuhc?controls=0&amp;start=77" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';

      close.onclick = function() {

        container.style.display = 'none';

        container.dataset.id = undefined;

        content.innerHTML = '';

      };

    }

  });

</script>

well the code is there in the separe index.html @wojtek

  1. I don’t see your code in the source of https://meet.kazooie.io/ventusst/. Have you placed the modified index.html or body-end.html in the scene folder before uploading the scene?

  2. viewer.addMenuButton('<https://icons.kazooie.io/shopping_cart.svg>') shouldn’t use angle brackets from the example placeholder. Change it to viewer.addMenuButton('https://icons.kazooie.io/shopping_cart.svg') .

1 Like

Hi, sorry for the absense:

  • Here you have a new scene files:

(link removed)

Could you write in more details what the issue with the button in this scene is? The extra menu button shows up and opens a pop-up with YT video when clicked.

1 Like

Hey Woj,

You are completely right, I guess I messed up my scenes…I’m improving my organization in order to prevent these flaws. Thanks.