Open Zeraan opened 5 years ago
Public comment from Luce Luo in Zendesk ticket #29163:
Dear Zeraan,
Thank you for contacting DJI. To help us collect questions in detail, please fill in the form below and we will handle this ticket once we have received it. https://formcrafts.com/a/dji-developer-feedback-en
Thanks,
Luce Luo DJI Dev Team
Use the following functions to fetch the data from the sd card, please let me know if you need sth else!
func loadMediaList() {
loadingIndicator.isHidden = false
if (self.mediaManager?.sdCardFileListState == DJIMediaFileListState.syncing || self.mediaManager?.sdCardFileListState == DJIMediaFileListState.deleting) {
print("Media Manager is busy. ")
} else {
self.mediaManager?.refreshFileList(of: DJICameraStorageLocation.sdCard, withCompletion: { (error) in
if error != nil {
print("Fetch media file list failed: ",error?.localizedDescription as Any)
} else {
print("Fetch media file list success.")
let mediaFileList = self.mediaManager?.sdCardFileListSnapshot()
self.updateMediaList(mediaFileList: mediaFileList!)
self.loadingIndicator.isHidden = true
}
})
}
}
func updateMediaList(mediaFileList: [DJIMediaFile]) {
//change the DJIMedia File type to NS Array
let newNSArray = mediaFileList as NSArray
self.mediaList?.removeAllObjects()
//here is a very important step to change from an NSArray NSMutuableArray
self.mediaList = newNSArray.mutableCopy() as? NSMutableArray
let taskScheduler = self.fetchCamera()?.mediaManager?.taskScheduler
taskScheduler?.suspendAfterSingleFetchTaskFailure = false
taskScheduler?.resume(completion: nil)
for file in mediaFileList {
if file.thumbnail == nil {
let task = DJIFetchMediaTask(file: file, content: DJIFetchMediaTaskContent.preview, andCompletion: { (file, content, error) in
self.mediaTableView.reloadData()
})
taskScheduler?.moveTask(toEnd: task)
}
}
}//end of the update func
I'm working on an issue in iOS where in some situations, refreshFileList never calls completion, and would constantly return "camera is busy" error when I add a timer to ping the DJIMediaFileListState.
I've noticed that this is a problem most commonly encountered on sd cards that have many images, in range of thousands. Android's version seems to work fine (identical workflow in that I set the camera mode to download, then check the state and if it's incomplete, reset, or unknown, call the refreshFileList) as of 4.11 on both Android and iOS version of DJI SDK.