该相机正在被另一个应用程序使用

问题描述 投票:0回答:1

我正在使用opentok开发webRTC应用程序。该应用程序运行正常。我将应用程序转换为库并通过将其添加到另一个项目来启动库活动。该应用程序正在连接到服务器,但相机未打开。我收到相机错误如下

E/opentok-videocapturer: The camera is in use by another app
                                                                 java.lang.RuntimeException: Fail to connect to camera service
                                                                     at android.hardware.Camera.<init>(Camera.java:518)
                                                                     at android.hardware.Camera.open(Camera.java:360)
                                                                     at com.opentok.android.DefaultVideoCapturer.init(DefaultVideoCapturer.java:110)
                                                                     at com.opentok.android.BaseVideoCapturer.initTrap(BaseVideoCapturer.java:223) 
android camera opentok
1个回答
0
投票
public boolean isCameraUsebyApp() {
        Camera camera = null;
        try {
            camera = Camera.open();
        }
        catch (RuntimeException e)
        {
            return true;
        }
        finally
        {
            if (camera != null)
            {
                camera.release();
            }
        }
        return false;
    }
© www.soinside.com 2019 - 2024. All rights reserved.