Search code examples
androidandroid-camerawebrtcpubnub

Pubnub deactive webcam but still stream


So I am using the sample pubnub Android Project and the sample pubnub web Project so that one can call from the webinstance to the Android user.

That works so far, but the webuser needs to have a microphone to be able to call the Android user. In my case the web user shall only be able to see the Android user. So the Video shall stream from the Android device to the Webpage and the Audio shall stream to both directions.

How to accomplish this?

I think These function / lines define it but I could not make it work:

function phoneStart() {
    console.log("inside phoneStart function");
    var phone = window.phone = PHONE({
        number: userId || "Anonymous", // listen on username line else Anonymous
        publish_key: pkey.value,     // Your Pub Key
        subscribe_key: skey.value, // Your Sub Key
    });
    phone.ready(function () { // not getting logged
        console.log("Phone ON!");
    });
    phone.receive(function (session) { 
        console.log("inside phone.receive"); // not getting logged
        session.message(message);
        session.connected(function (session) {
            console.log("inside session.connected"); // not getting logged
            video_out.innerHTML = "";
            video_out.appendChild(session.video);
        });
        session.ended(function (session) { video_out.innerHTML = ''; });
    });
}

Solution

  • Try using the media init parameter like this:

    var phone = window.phone = PHONE({ 
        number: userId || "Anonymous", 
        publish_key: pkey.value, 
        subscribe_key: skey.value, 
        media: { 
            audio : true, 
            video : false /*turn off camera*/ 
        } 
    });