1

I want to receive audio/video without accepting the permission that browser asks to access mic/cam. Is it possible?

I'm using SimpleWebRTC, my code is here:

// create our webrtc connection
var webrtc = new SimpleWebRTC({
    // the id/element dom element that will hold "our" video
    localVideoEl: 'localVideo',
    // the id/element dom element that will hold remote videos
    remoteVideosEl: '',
    // immediately ask for camera access
    autoRequestMedia: true,
    debug: false,
    detectSpeakingEvents: true,
    autoAdjustMic: false,
    media: {
        video: {
            frameRate: {
                max: 30
            },
            width: {
                max: 176
            },
            height: {
                max: 144
            }
        },
        audio: true
    },
});
  1. If I delete this => autoRequestMedia: true or change it to false, so it doesn't ask to get permission and the result is NOTHING :(
  2. If I leave this => autoRequestMedia: true to be true, so the browser asks to get permission,

    2-1: if I don't accept, the result is NOTHING :( 2-2: if I accept, it works :)

So my problem is how I can receive(not send) data(audio/video) without accepting that permission popup or even set that autoRequestMedia to false and receive data?

Thanks

amateur
  • 51
  • 1
  • 8
  • 1
    Duplicating your [own question](http://stackoverflow.com/questions/38435103/can-i-receive-video-without-giving-permission-to-browser-to-use-my-camera-in-sim)? You are telling simplewebrtc that you want media which means it will wait until it gets it. – Philipp Hancke Jul 26 '16 at 06:34
  • My question: Why we can't receive data(audio/video) without connecting mic/cam and accepting that permission popup? – amateur Jul 26 '16 at 06:52
  • Because using the mic/cam from a webpage requires permission from the user... – Kevin Jul 26 '16 at 11:34
  • @Kevin I know, but I don't want to use it for sending but receiving. – amateur Jul 26 '16 at 12:45
  • 2
    The permission prompt comes when calling getUserMedia, SimpleWebRTC seems to call that quite a lot. If you want more control over this you'll have to use WebRTC and manage the media yourself instead of using SimpleWebRTC. – Kevin Jul 26 '16 at 13:07
  • @Kevin OK could you help me in WebRTC just in this specific problem I have? – amateur Jul 26 '16 at 13:30
  • With WebRTC itself it's easy, just don't call getUserMedia. That means you won't be able to create a local media stream, so you can't add a local stream to the peerconnection, but other than that there shouldn't be any significant difference with a regular WebRTC app. – Kevin Jul 26 '16 at 13:53
  • Thanks dear Kevin :) – amateur Jul 27 '16 at 06:42

1 Answers1

0

This is a browser restriction. Otherwise any application could open your devices silently in the background and listen for you.

However it is possible to call getUserMedia() only once at your app start (this is where the popups appears) and reuse that onward everywhere thus preventing any additional popups at incoming audio/video.

Istvan
  • 1,591
  • 1
  • 13
  • 19