首页 > 解决方案 > 修改“Skype for Business SDK”摄像头实例的旋转

问题描述

我正在寻找使用Skype for Business SDK (SfbSDK) 为 Android 开发视频会议应用程序。

太看看我是否能够满足一些需求,我使用Office 开发团队分配的 SfbSDK 克隆了示例应用程序的 git 存储库,可在此处获得

如果示例应用程序允许我广播前置摄像头和/或后置摄像头,我找不到任何允许我修改摄像头实例的参数,除了更改目标摄像头(前、后...)。

我想要的(至少)是在您将手机切换到横向模式时修改旋转(修改其他参数也很好,比如Camera.Parameters)。

因为如果您使用示例应用程序尝试它,预览(在手机上)和传出视频都变成如下所示。

转出和预览显示

因此,我尝试创建一个实例android.hardware.Camera并将其设置为活动相机,方法如下:

videoService.setActiveCamera(com.microsoft.office.sfb.appsdk.Camera)

但它不起作用......或者我做错了......!

这甚至可能!?

欢迎任何建议。

标签: androidskype-for-businessskypedeveloper

解决方案


不久前回到项目,我终于找到了解决方案

DeviceRotationMonitor.getInstance().onRotation(Context context);

干活!!
希望它有所帮助。


编辑:正如@miecio 在下面的评论中所问的,有关如何使用此答案的更多信息。

如果您使用的是Skype for Business SDK,您可以在文档中找到一个帮助类(此处),它授予您一些与之交互的功能以及一些回调处理程序来接收它的不同状态。

在这个帮助类中,您将找到以下方法:

public class ConversationHelper {
    ...
    /**
     * Setup the Video preview.
     * @param texture SurfaceTexture
     */
    private void surfaceTextureCreatedCallback(SurfaceTexture texture) {
        try {
            // Tie the video stream to the texture view control
            videoService.showPreview(texture);

            // Check state of video service.
            // If not started, start it.
            if (this.videoService.canStart()) {
                this.videoService.start();
            } else {
                // On joining the meeting the Video service is started by default.
                // Since the view is created later the video service is paused.
                // Resume the service.
                if (this.videoService.canSetPaused()) {
                    this.videoService.setPaused(false);
                }
            }
            setSkypeOrientation();
        } catch (SFBException e) {
            e.printStackTrace();
        }
    }
    ...
}

在那里我添加了以下指令:setSkypeOrientation()
这是为了在创建表面后设置正确的屏幕方向(默认情况下,即使您不添加它,屏幕方向也应该是好的)。

此外,在实现助手类的活动中,我已经覆盖了onConfigurationChanged(Configuration newConfig)如下:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (mConversationHelper != null) {
        mConversationHelper.setSkypeOrientation();
    }
}

该部分用于处理并设置正确的屏幕方向。

最后,在setSkypeOrientation()中,我只是简单地使用了第一版答案中的上述说明。

public class ConversationHelper {
    ...
    public void setSkypeOrientation() {
        DeviceRotationMonitor.getInstance().onRotation(mContext);
    }
    ...
}

注意:该类DeviceRotationMonitor是从以下位置导入的:
import com.microsoft.office.lync.platform.DeviceRotationMonitor;

至少这是我使用它的方式,您可以根据您的用例进行调整。
希望“编辑”使使用更加清晰。


推荐阅读