我目前正在编写一个从 Inspire 1 下载所有图像的 Android 应用程序。我正在使用最新版本的 SDK (v3.2.1)。我正在使用 DJIPlaybackManager 来执行此操作。但是,我在下载所有图像时遇到了问题。
每当我运行下面的代码时,我都会得到“未选择文件”,即使在它上面我认为我选择了 SD 卡上的所有文件。CameraFileDownloadCallback 中的 onError 方法会引发此错误。selectAllFiles() 返回的错误为空,所以我相信这意味着它选择正确。有人可以告诉我我做错了什么吗?我尝试了很多东西,但似乎没有任何效果。
任何帮助将不胜感激。
private static String TAG = "MediaManager";
public static void downloadAllMedia(final Context mContext) {
Log.d(TAG, "Downloading media...");
final String fileDirPath = mContext.getFilesDir().getPath();
DJIBaseProduct product = DJIDemoApplication.getProductInstance();
if (product != null && product.isConnected()) {
if (product instanceof DJIAircraft) {
final DJICamera camera = product.getCamera();
if (camera != null) {
camera.setCameraMode(DJICameraSettingsDef.CameraMode.Playback, new DJIBaseComponent.DJICompletionCallback() {
@Override
public void onResult(DJIError djiError) {
if (djiError == null) {
final DJIPlaybackManager playbackManager = camera.getPlayback();
DJICameraError enterPreviewModeError = playbackManager.enterMultiplePreviewMode();
if(enterPreviewModeError != null) {
Log.e(TAG, "Failed to enter mutliple preview mode");
}
DJICameraError enterEditModeError = playbackManager.enterMultipleEditMode();
if(enterEditModeError != null) {
Log.e(TAG, "Failed to enter multiple edit mode: " + enterEditModeError.getDescription());
return;
}
DJIError selectFilesError = playbackManager.selectAllFiles();
if (selectFilesError != null) {
Log.e(TAG, "Failed to select files on device: " + selectFilesError.getDescription());
return;
} else {
Log.d(TAG, "Successfully selected all media");
}
playbackManager.downloadSelectedFiles(new File(fileDirPath), new DJIPlaybackManager.CameraFileDownloadCallback() {
@Override
public void onStart() {
Log.d(TAG, "Starting fetch of media");
}
@Override
public void onEnd() {
Log.d(TAG, "Finished downloading media");
}
@Override
public void onError(Exception e) {
Log.e(TAG, "Failed downloading media: " + e.getMessage());
}
@Override
public void onProgressUpdate(int i) {
Log.d(TAG, "Media download from drone: " + i + "%");
}
});
} else {
Log.e(TAG, "Could not set the Camera mode to playback");
}
}
});
} else {
Log.e(TAG, "Camera is not available");
}
}
}
}