Mobile-SDK-iOS
Mobile-SDK-iOS copied to clipboard
Camera is busy or the command is not supported in the camera's current state(code:-3002)
When i try to get the last captured image, i'm getting this error: Camera is busy or the command is not supported in the camera's current state(code:-3002). Always newMedia.fetchData callback throws this error.
func camera(_ camera: DJICamera, didGenerateNewMediaFile newMedia: DJIMediaFile) {
print("Generate new media file: \(newMedia.fileName), duration: \(newMedia.durationInSeconds)")
newMedia.fetchThumbnail { (error) in
let image = newMedia.thumbnail
}
getImages(with: newMedia)
newMedia.fetchData(withOffset: 0, update: DispatchQueue.main, update: {(_ data: Data?, _ isComplete: Bool, _ error: Error?) -> Void in
let manager = camera.mediaManager!
if error != nil {
print("State: \(manager.sdCardFileListState.rawValue)")
print("Error downloading photo: \(error!)")
}
else {
if let data = data, let downloadedImage = UIImage(data: data) {
print("Image was downloaded!")
print(downloadedImage)
}
}
})
}
Agent comment from Luce Luo in Zendesk ticket #48323:
Dear Customer,
Thank you for contacting DJI. It should be the DOWNLOAD mode first, please check it setMode:withCompletion.
Thanks,
Luce Luo
DJI Developer Support
°°°
Hello. I'm having the same problem. But I'm using Mini 2 and apparently setMode is not supported.. I tried to add camera.enterPlayback(), but no success.
func camera(_ camera: DJICamera, didGenerateNewMediaFile newMedia: DJIMediaFile) {
camera.enterPlayback()
newMedia.fetchData(withOffset: 0, update: DispatchQueue.main, update: { [self](_ data: Data?, _ isComplete: Bool, _ error: Error?) -> Void in
if error != nil {
testlabel.text = "\(error!.localizedDescription)"
print("State:")
print("Error downloading photo: \(error!)")
}
else {
// unwrap downloaded data and create image
guard let data = data else {return}
let downloadedImage = UIImage(data: data)
pictureview.image = downloadedImage
}
guard isComplete else {return}
camera.exitPlayback()
})