Android getsupportedvideosizes returns null on emulator

前端 未结 4 1387
轻奢々
轻奢々 2021-01-27 14:22

I have tried to get the supported video size as below in an emulator but it always return null.Why it is so?I have tried in 4.03.Thanks in advance

 Camera cam         


        
相关标签:
4条回答
  • 2021-01-27 14:55

    Here is the one of the option by which you can get Camera Preview Size of the devices.

    Camera camera=Camera.open();
    android.hardware.Camera.Parameters params = camera.getParameters();
    Size supportedPicSizes = params.getPreviewSize();
    if (supportedPicSizes==null){
          Log.i("*****supportedVideoSize*****", "*****Null****"); 
    }
    else{
          Log.i("*****supportedVideoSize*****", "*****"+supportedPicSizes.height); 
          Log.i("*****supportedVideoSize*****", "*****"+supportedPicSizes.width); 
    }
    

    Hope it helps you.

    Thanks.

    0 讨论(0)
  • 2021-01-27 15:10

    answered also here

    Sample code:

    public List<Size> getSupportedVideoSizes(Camera camera) {
        if (camera.getParameters().getSupportedVideoSizes() != null) {
            return camera.getParameters().getSupportedVideoSizes();
        } else {
            // Video sizes may be null, which indicates that all the supported
            // preview sizes are supported for video recording.
            return camera.getParameters().getSupportedPreviewSizes();
        }
    }
    
    0 讨论(0)
  • 2021-01-27 15:14

    This is a known Android bug.

    This still hasn't been fixed yet but the fact that it is on the bug tracking system probably means that Google has plans to see it through.

    0 讨论(0)
  • 2021-01-27 15:18

    It's clearly stated here that a null return from this method means the device doesn't support different outputs for preview and video. In case of emulator, this situation must be prominent because an emulator doesn't have a physical camera and is generally not used for testing camera-related modules.

    I would like to add that even though documentations have pointed this to be a normal case scenario, I'm still unable to find a proper alternative for devices suffering from this sickness. For instance, a Verizon variant of S3 return null for both "getSupportedVideoSizes()" and "getPreferredPreviewSizeForVideo()". Has anyone gone through a way around this issue?? A help would be highly appreciated.

    0 讨论(0)
提交回复
热议问题