UIImagePickerController - Camera not ready

2019-06-23 23:15发布

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

2条回答
Root(大扎)
2楼-- · 2019-06-23 23:52

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

查看更多
男人必须洒脱
3楼-- · 2019-06-23 23:53
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;
            }
        }
查看更多
登录 后发表回答