"AVCaptureDevice devicesWithMediaType" not find device.

We used usb camera.


first,

NSArray *arrayList = [AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo];

then

2 found camera (usb camera, FaceTime HD camera)


and

Disconnected usb camera. (unmount, remove)

and

connected usb camera (mount, insert)


NSArray *arrayList = [AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo];

1 found camera (FaceTime HD camera)

not found usb camera.


How can we solved?

Replies

We're having a similar issue. Were you able to find a solution?


Thanks,

jay

Does the device never come back, or just does it not come back as soon as you'd like?

The device never comes back. A brief delay (less than 10 seconds) would be no big deal.

]Just a little context, this is a FireWire based camera. I made a little demo app that just polls [AVCaptureDevice devices] when it sees the notifications of connecting / disconnecting devices. That works as expected. The camera can be added and removed. It's just in our production app where we actually record video from the camera that it never sees the device if it is removed and reconnected.

I've found a solution for our issue. When the device was disconnected, the app showed a modal dialog ([NSApp runModalForWindow:..]) to inform the user that the device had been disconnected and should be reconnected. It appears that while the modal event loop for this window is running, the output of [AVCaptureDevice devices] doesn't update.


I switch from '[NSApp runModalForWindow:..]' to '[parentWindow beginSheet...]' to display the window as a sheet which doesn't use a new run loop and now the list of capture devices updates as expected.

You were probably blocking the main runloop. Lots of important notifying happens on the main run loop.