stephenlb / webrtc-sdk

WebRTC Simple Calling API + Mobile SDK - A simplified approach to RTCPeerConnection for mobile and web video calling apps.
https://stephenlb.github.io/webrtc-sdk/
MIT License
853 stars 278 forks source link

1 to many Broadcast, prevent viewer from send audio #71

Open munajaf opened 5 years ago

munajaf commented 5 years ago

Hi, ive tried following the docs that you have made. https://github.com/stephenlb/webrtc-sdk#viewer

everything works fine, i just want to make the viewer cant send any audio and video just want them to listen to the broadcast.,

tried using the autocam: false on the viewer side. but the viewer cant hear anything after i did it

stephenlb commented 5 years ago

Nice! Try adding media : { audio : true, video : true }, to the BROADCASTER. Something like this:

var broadcaster = PHONE({
    number        : "BROADCASTER",  // If you want more than one broadcaster, use unique ids
    media         : { audio : true, video : true }, // <----------------
    publish_key   : 'pub-c-561a7378-fa06-4c50-a331-5c0056d0163c',
    subscribe_key : 'sub-c-17b7db8a-3915-11e4-9868-02ee2ddab7fe',
    ssl           : true
});
munajaf commented 4 years ago

Thank you for your response! tried like what you have told me to do. when i made the viewer autocam became true, then i will receive the audio. down here is my initialize.

BROADCASTER

var broadcaster = PHONE({
                number        : "BROADCASTER",  // If you want more than one broadcaster, use unique ids
                publish_key   : 'pub-c-*',
                subscribe_key : 'sub-c-*',
                media         : { audio : true, video : true },
                ssl           : true
            });

VIEWER

    var viewer = PHONE({
        number        : "VIEWER-"+new Date,
        publish_key   : 'pub-c-*',
        subscribe_key : 'sub-c-*',
        media         : { audio : true, video : true },
        autocam       : false,
        ssl           : true
    });
stephenlb commented 4 years ago

I've tried many variations without success.

stephenlb commented 4 years ago

Okay I have something that may be a starting point for you. Try these files:

Broadcaster SOURCE https://github.com/stephenlb/webrtc-sdk/blob/master/tutorials/broadcaster.html

Viewers SOURCE https://github.com/stephenlb/webrtc-sdk/blob/master/tutorials/viewer.html

stephenlb commented 4 years ago

Demo links will help. The autocam:off isn't being used for the demo. However this may get you closer to what you are looking for.

Broadcaster: https://stephenlb.github.io/webrtc-sdk/tutorials/broadcaster.html Viewer: https://stephenlb.github.io/webrtc-sdk/tutorials/viewer.html

munajaf commented 4 years ago

Thank you for your help, the only way to make the viewer not sending any audio is by using viewer.camera.toggleAudio(); when the broadcaster is connected so that it will mute the viewer

which is just a workaround, the viewer will still request for webcam permission, which is not security wise. some of my user will be asking regarding this permission maybe i'll just have to explain it to them.