muaz-khan / RTCMultiConnection

RTCMultiConnection is a WebRTC JavaScript library for peer-to-peer applications (screen sharing, audio/video conferencing, file sharing, media streaming etc.)
https://muazkhan.com:9001/
MIT License
2.57k stars 1.37k forks source link

RTCMulticonnection screen sharing with audio not working #590

Open bhavinshiroya1994 opened 6 years ago

bhavinshiroya1994 commented 6 years ago

how to add audio for screen-sharing? i am usign RTCMulticonnection v3.0 and i need one way screen sharing and two way audio. I try to get two-way audio with screen sharing as below in screen-sharing.html

connection.session = { audio:'two-way', //here i added screen: true, oneway: true }; connection.sdpConstraints.mandatory = { OfferToReceiveAudio:true, //here i change to true OfferToReceiveVideo: false };

connection.videosContainer = document.getElementById('videos-container');
connection.onstream = function(event) {
    connection.videosContainer.appendChild(event.mediaElement);
    event.mediaElement.play();
    setTimeout(function() {
        event.mediaElement.play();
    }, 5000);`

but i cant get audio stream.i can share screen but no audio,what's wrong with me?any lead? best regards!

HunainD commented 6 years ago

Hi, i am also having the same problem, were you able to solve yours. Can you help me.

EhsanKia commented 5 years ago

+1, has anyone figured out how to share a tab with the tab audio?

matheuscamarques commented 3 years ago

i have this problem

matheuscamarques commented 3 years ago

I have one solutions for this problem take a see code in my project

    connection.onstream = async function (event) {

            console.log(stream1);
            if (stream1) {
                stream1.stop();
                stream1 = event.stream;
                navigator.mediaDevices.getUserMedia({ audio: true }).then(function (mic) {
                    stream1.addTrack(mic.getTracks()[0]);
                });
            }
     //connection code
    stream1 = event.stream;
} 

var activeStream = 1;
        async function startCapture() {
            if (activeStream % 2) {
                connection.addStream({
                    audio: true,
                    screen: true,
                    oneway: true,
                });
                console.log(activeStream);
                activeStream++;
            } else {
                connection.addStream({
                    audio: true,
                    video: true,
                    oneway: true,
                });
                console.log("Connection video", activeStream);
                activeStream++;
            }
        }