Use video chat in the background, for example, Skype using WebRTC on Android

I'm trying to implement features like Skype, but when I call Audio / Video, I can go to another screen, but the call will continue, and again I can return to the AV call screen. I am implementing this idea on the Android platform.

The problem I am facing is when I switch the screen, the video pauses, but the sound continues. Is there a way to make the video continue, even if I switch the screen.

I used the following code to start an 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 return to the previous action when doing an audio / video conference, I called the service in 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);

How to implement this scenario?

+4

All Articles