在Android中使用WebRTC在Skype等后台使用视频聊天

时间:2016-04-09 07:02:35

标签: android audio video webrtc videochat

我正在尝试实现像Skype这样的功能,即在进行音频/视频通话时,我可以转到另一个屏幕,但是呼叫将继续,并且我可以再次返回到AV呼叫屏幕。我正在Android平台上实现这个想法。

我面临的问题是当我切换屏幕时,视频暂停,但音频仍在继续。即使我切换屏幕,有没有办法让视频继续播放。

我使用以下代码从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);

当我在进行音频/视频会议时回到上一个活动时,我将服务调用到了strat startLocalMedia

这是我的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);

如何实施此方案?

0 个答案:

没有答案