Skip to content Skip to sidebar Skip to footer

Networked A-frame Issue With Dynamic-room And Video

I am creating a project using A-frame (https://aframe.io) and the networked A-frame component (https://www.npmjs.com/package/networked-aframe) (project at: https://glitch.com/edit/

Solution 1:

This is a follow up to this question.

Your dynamic-room only sets the room id, and emits connect so the networked-scene attempts to connect to the server:

// public/js/dynamic-room.component.js

// Setup networked-scene
var networkedComp = {
  room: params.room
};
// set the room
el.setAttribute("networked-scene", networkedComp);    
// emit connect
el.emit("connect", null, false);

in this case, its not an alternative to networked-scene, they work together. If you disable auto-connect before the scene:

<script>
AFRAME.components["networked-scene"].schema.connectOnLoad.default = false;
</script>
<a-scene dynamic-room networked-scene>

The video shows up as expected (glitch here)


If you want the dynamic-room to do all setup which is in the networked-scene, then Michaels answer is also correct.


Solution 2:

You are on the right track.

I assume you want to use dynamic-room to load a custom room name from the URL. (That is all it is for. If that is not what you want, then dynamic-room is not what you are looking for.)

The dynamic room example reads the URL, then creates the "networked-scene" component for you and attaches it to your tag.

It is an old example, written before video support, so it does not check for video: true:

var isMultiuser = params.hasOwnProperty('room');
var webrtc = params.hasOwnProperty('webrtc');
var adapter = webrtc ? 'easyrtc' : 'wseasyrtc';
var voice = params.hasOwnProperty('voice');

var networkedComp = {
    room: params.room,
    adapter: adapter,
    audio: voice //<--Only setting the audio property here
};
console.info('Init networked-aframe with settings:', networkedComp);
el.setAttribute('networked-scene', networkedComp);

I recommend copying your parameters into dynamic-room.component.js (at line 18).

Only the room name will load from the URL. (And will default to 'audio' if not specified, just like your networked-scene parameter.)

var roomNameFromURL = params.hasOwnProperty('room');
//We won't check for these:
//var webrtc = params.hasOwnProperty('webrtc');
//var adapter = webrtc ? 'easyrtc' : 'wseasyrtc';
//var voice = params.hasOwnProperty('voice');

var networkedComp = {
    //if there is no name in the URL, default to 'audio',
    //  like your networked-scene
    room: roomNameFromURL ? params.room : 'audio',
    adapter: 'easyrtc',
    audio: true,
    video: true,
    debug: true
};
console.info('Init networked-aframe with settings:', networkedComp);
el.setAttribute('networked-scene', networkedComp);

Post a Comment for "Networked A-frame Issue With Dynamic-room And Video"