javascriptthree.jsaframewebvraframe-networked

Networked A-frame examples toggle video not working


I have created a remix of the Networked A-frame examples project. I've been testing out some features and for some reason, the toggle video button in the bottom left corner of the screen isn't working on the video example.

The function is triggering however it isn't changing the video from on to off and vice versa. I'm not sure why this is, but I'm wondering how I can make it so when the button is clicked, if video is on, it will turn off and if video is off, it will turn on. How can this be done? The code is found in public/examples/index.html at line 106 of this project:

https://glitch.com/edit/#!/modern-talented-tanker?path=examples%2Findex.html%3A116%3A0

Code snippet that isn't working:

// Handle camera button click (Off and On)
        cameraBtnEle.addEventListener('click', function() {
          NAF.connection.adapter.enableCamera(!cameraEnabled);
          cameraEnabled = !cameraEnabled;
          cameraBtnEle.textContent = cameraEnabled ? 'Hide Camera' : 'Show Camera';
        });
      }

Solution

  • I've looked into the file You linked to, the code snippet found there doesn't match with the one you posted here, it references to the mic element in the linked file. What can i suggest is that you look into the example file called basic-video.html. You can find there the correct setup for video sharing in VR space. Remember to test it on 2 tabs / windows as if there is only one "player" the video sharing won't work.

    For a detailed guide about video sharing in networked-aframe visit this link: https://github.com/networked-aframe/networked-aframe#video

    This is the example with video sharing:
    https://modern-talented-tanker.glitch.me/basic-video.html

    Source code:
    https://glitch.com/edit/#!/modern-talented-tanker?path=examples%2Fbasic-video.html

    Good luck!