UIImagePickerController - Camera not ready

非 Y 不嫁゛ 提交于 2019-12-10 17:16:25

问题


I'm developing an iPhone app that records video. I create a UIImagePickerController, limit it to video recording then programatically ask the camera to startVideoCapture. Unfortunatly when I run the app I get the following in the console;

"UIImagePickerController: ignoring request to start video capture; camera is not yet ready."

Obviously the iPhone is not done setting things up.

Is there a way that I can check the setup process has completed before starting to record?

Many thanks in advance.

Rich


回答1:


startVideoCapture should return NO when it can't record. You can check that if needed.




回答2:


UIImagePickerController *picker;  

Check if camera is ready or NOT !

I have same button for star and stop hence a bool cameraIsOn

if ([UIImagePickerController isCameraDeviceAvailable:[picker cameraDevice]]) {
            if (cameraIsOn) {
                NSLog(@"stop camera");
                [picker stopVideoCapture];
                cameraIsOn = FALSE;
            }
            else {
                NSLog(@"start camera");
                [picker startVideoCapture];
                self.videoTimer =  [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeValue) userInfo:nil repeats:YES];
                cameraIsOn = TRUE;
            }
        }


来源:https://stackoverflow.com/questions/4377303/uiimagepickercontroller-camera-not-ready

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!