Use Video chat in background like Skype using WebRTC in Android

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Apr 10, 2016 5:56:37 PM via Website

I am trying to implement functionality like Skype i.e while having Audio/Video call I can go to another screen, but the call will continue, and again I can return to the AV calling screen. I am implementing this idea in Android platform.

The problem I am facing is when I switch the screen, the video is paused, but the audio is continuing. Is there any way to make video continue even if I switch the screen.

I used following code to start the Audio/Video conference from VideoChatActivity.java`

app.startLocalMedia(new SingleAction<Exception>() {
        @Override
        public void invoke(Exception ex) {
            if (ex == null) {
                // Start the signalling engine.
                app.startSignalling(new SingleAction<String>() {
                    @Override
                    public void invoke(String ex) {
                        if (ex != null) {
                            // alert("Could not start signalling. %s",
                            // ex.getMessage());
                            alert("Some problem occured while establishing connection");
                            Logger.error("YES-Error at startSignalling " + ex);
                        }
                    }
                }, webasyncURL);
                // Start the conference engine.
                Logger.error("YES-here-1.2");
                app.startConference(iceLinkServerAddress, roomName, video, container, wheel, audioOnlyDefaultAvatar,
                        muteControlToggle, videoOnOffToggle, speakerToggle, videoChatActivity,
                        new SingleAction<Exception>() {
                            @Override
                            public void invoke(Exception ex) {
                                if (ex != null) {
                                    // alert("Could not start conference. %s",
                                    // ex.getMessage());
                                    alert("Some problem occured while initializing video call");
                                    Logger.error("YES-Error at startconference " + ex.getLocalizedMessage());
                                }
                            }
                        });
            } else {
                // alert("Could not start local media. %s",
                // ex.getMessage());
                Logger.error("YES-Error at startLocalMedia " + ex.getLocalizedMessage());
            }
        }
    }, video, audio);

When I back to the previous activity while doing Audio/Video conference I called the service to strat startLocalMedia.

Here is my CameraService.java`

VideoChatActivity.app.startLocalMedia(new SingleAction<Exception>() {
            @Override
            public void invoke(Exception ex) {

                if (ex == null) {
                    // Start the signalling engine.
                    VideoChatActivity.app.startSignalling(new SingleAction<String>() {
                        @Override
                        public void invoke(String ex) {
                            if (ex != null) {
                                // alert("Could not start signalling. %s",
                                // ex.getMessage());
                                //alert("Some problem occured while establishing connection");
                                Logger.error("YES-Error at startSignalling " + ex);
                            }
                        }
                    }, VideoChatActivity.webasyncURL);
                    // Start the conference engine.

                    VideoChatActivity.app.startConference(VideoChatActivity.iceLinkServerAddress, VideoChatActivity.roomName, VideoChatActivity.video, VideoChatActivity.container, VideoChatActivity.wheel, VideoChatActivity.audioOnlyDefaultAvatar,
                            VideoChatActivity.muteControlToggle, VideoChatActivity.videoOnOffToggle, VideoChatActivity.speakerToggle, VideoChatActivity.videoChatActivity,
                            new SingleAction<Exception>() {
                                @Override
                                public void invoke(Exception ex) {

                                    if (ex != null) {
                                        // alert("Could not start conference. %s",
                                        // ex.getMessage());
                                        //alert("Some problem occured while initializing video call");
                                        Logger.error("YES-Error at startconference " + ex.getLocalizedMessage());
                                    }
                                }
                            });
                } else {
                    // alert("Could not start local media. %s",
                    // ex.getMessage());
                    //alert("Some problem occured while getting media devices");
                    Logger.error("YES-Error at startLocalMedia " + ex.getLocalizedMessage());
                }
            }
        }, VideoChatActivity.video, VideoChatActivity.audio);