Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen to peer connections #4

Open
dawado opened this issue Jun 9, 2021 · 0 comments
Open

Listen to peer connections #4

dawado opened this issue Jun 9, 2021 · 0 comments

Comments

@dawado
Copy link

dawado commented Jun 9, 2021

Hello, I have some problems in doing a connection to an existing audio room. I'm creating an audio room, where two or more user can talk to each other:

This is my initial code on opening the page:

`
async initAudioRoom() {
const roomName = "raumname"

            const channel = new rtc.WebSocketChannel("wss://easy.innovailable.eu/" + encodeURI(roomName));
            const signaling = new rtc.MucSignaling(channel);
            const options = {
                stun: "stun:stun.innovailable.eu",
            }
            var room = new rtc.Room(signaling, options)
            this.room = room

            var current_this = this

            this.room.on('peer_joined', function(peer) {
                // create a video tag for the peer
                const view = $('<video playsinline autoplay>');
                $('#peers').append(view);
                const ve = new rtc.MediaDomElement(view[0], peer);
                // remove the tag after peer leftd
                peer.on('left', function() {
                    view.remove();
                });
            });
        },`

When someone wants to join the audio room I'm doing this:

`
const roomName = "raumname"

 try {
                // create a local stream from the users camera
                const stream = await this.room.local.addStream({ video: false, audio: true });

                // display that stream
                const ve = new rtc.MediaDomElement($('video'), stream);
            } catch(err) {
                alert("Unable to get stream, please give permission. You might have to go into settings if you denied before.");
                return;
            }

           try {
                await this.room.connect();
            } catch(err) {
                alert("Unable to join room: " + err.message)
            }

`

This works fine.. two or more user can talk to each other. Now I just try to define a function for a user, that only can listen to the users who are in the audio room.. how can I do this? The listening user have already the video tags of the peers, which are in the audio room, at the DOM. But the listening user can't hear anything. I tried something like a Listening Button and this function:

try { await this.room.join(); } catch(err) { alert("Unable to join room: " + err.message) }

Do you have an idea and could help me? Im trying it since days and im not able to finish that.

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant