Ferdinandindan
lvl.1
Spain
Offline
|
I'm trying to build an app on MSDK to get the multimedia files on SD card.
I have tried to follow the scheme of MediaManager guide Media File Sample on DJI MSDK Documentation. I'm using MSDK v5.
The following code executes when i click a button on the UI of my app.
Log.d("Pruebas","Botón pulsado");
MediaDataCenter.getInstance().getMediaManager().addMediaFileListStateListener(new MediaFileListStateListener() {
@Override
public void onUpdate(MediaFileListState mediaFileListState) {
Log.d("Pruebas","Cambio en el estado de la lista de ficheros: "+mediaFileListState);
}
});
MediaDataCenter.getInstance().getMediaManager().enable(new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
Log.d("Pruebas","Completion Callback Con Exito");
MediaFileListDataSource mediaDataSource = new MediaFileListDataSource.Builder().build();
CameraStorageLocation location = CameraStorageLocation.valueOf("SDCARD");
mediaDataSource.setStorageLocation(location);
MediaListener mediaCallback = new MediaListener();
MediaDataCenter.getInstance().getMediaManager().setMediaFileDataSource(mediaDataSource);
if (String.valueOf(MediaDataCenter.getInstance().getMediaManager().getMediaFileListState()).equals("IDLE"))
{
Log.d("Pruebas","Entra If IDLE");
PullMediaFileListParam.Builder builder =new PullMediaFileListParam.Builder();
builder.count(-1);
builder.orderType(FileListRequestTimeOrderType.OLD_FIRST);
PullMediaFileListParam params = new PullMediaFileListParam(builder.mediaFileIndex(-1));
Log.d("Pruebas","Crea params "+ params.getCount() +" "+ params.getFilter()+" "+ params.getMediaFileIndex()+" "+ params.getOrderType());
if(String.valueOf(MediaDataCenter.getInstance().getMediaManager().getMediaFileListState()).equals("IDLE")) {
Log.d("Pruebas", "Estaba IDLE");
MediaDataCenter.getInstance().getMediaManager().pullMediaFileListFromCamera(params, new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
Log.d("Pruebas", "Finaliza");
while (String.valueOf(MediaDataCenter.getInstance().getMediaManager().getMediaFileListState()).equals("UPDATING")) {
try {
Log.d("Pruebas", String.valueOf(MediaDataCenter.getInstance().getMediaManager().getMediaFileListState()));
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
if (String.valueOf(MediaDataCenter.getInstance().getMediaManager().getMediaFileListState()).equals("UP_TO_DATE")) {
MediaFileListData mediaFileListData = MediaDataCenter.getInstance().getMediaManager().getMediaFileListData();
Log.d("Pruebas", "Ha cogido Lista");
if (mediaFileListData.getData().size() > 0) {
Log.d("Pruebas", "HayCosas");
mediaFileListData.getData().get(1).pullOriginalMediaFileFromCamera(1, mediaCallback);
}
}
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
Log.d("ErrorInvicsa", "Problemas al obtener la lista " + idjiError);
}
});
}
}
if (String.valueOf(MediaDataCenter.getInstance().getMediaManager().getMediaFileListState()).equals("UP_TO_DATE")) {
MediaFileListData mediaFileListData = MediaDataCenter.getInstance().getMediaManager().getMediaFileListData();
Log.d("Pruebas", "Ha cogido Lista");
if (mediaFileListData.getData().size() > 0) {
Log.d("Pruebas", "HayCosas");
mediaFileListData.getData().get(1).pullOriginalMediaFileFromCamera(1, mediaCallback);
}
}
if (String.valueOf(MediaDataCenter.getInstance().getMediaManager().getMediaFileListState()).equals("UPDATING"))
{
Log.d("Pruebas", "Actualizando");
}
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
Log.d("ErrorInvicsa","Error al activar MediaDataCenter " +idjiError);
}
});
Then i get this on the log of my app.
2024-03-26 09:07:35.641 3859-3859 Pruebas com.dji.sampleV5.aircraft D Botón pulsado
2024-03-26 09:07:36.304 3859-3859 CameraStreamManager com.dji.sampleV5.aircraft I (co_a:874) listenPlayingBack update: LEFT_OR_MAIN true
2024-03-26 09:07:36.325 3859-4049 StreamObserver com.dji.sampleV5.aircraft I (co_a:7) (LEFT_OR_MAIN) updateStreamSource ,channelId = -1 ,linkId = -1
2024-03-26 09:07:36.345 3859-3859 MediaManager com.dji.sampleV5.aircraft I (onSuccess:2) enter playback mode success
2024-03-26 09:07:36.353 3859-3859 MediaManager com.dji.sampleV5.aircraft I (onSuccess:2) backupchannel success
2024-03-26 09:07:36.353 3859-3859 Pruebas com.dji.sampleV5.aircraft D Completion Callback Con Exito
2024-03-26 09:07:36.357 3859-3859 Pruebas com.dji.sampleV5.aircraft D Entra If IDLE
2024-03-26 09:07:36.357 3859-3859 Pruebas com.dji.sampleV5.aircraft D Crea params -1 NONE 1 OLD_FIRST
2024-03-26 09:07:36.357 3859-3859 Pruebas com.dji.sampleV5.aircraft D Estaba IDLE
2024-03-26 09:07:36.357 3859-3859 Pruebas com.dji.sampleV5.aircraft D Cambio en el estado de la lista de ficheros: UPDATING
2024-03-26 09:07:36.362 3859-3859 Pruebas com.dji.sampleV5.aircraft D Actualizando
2024-03-26 09:07:36.439 3859-4099 MediaManager com.dji.sampleV5.aircraft I (co_a:124) Fetch file list failed, retCode -> 0 files -> [262169, 524313, 786457, 786473]filterNONE
2024-03-26 09:07:36.441 3859-4099 Pruebas com.dji.sampleV5.aircraft D Finaliza
2024-03-26 09:07:36.441 3859-4099 Pruebas com.dji.sampleV5.aircraft D UPDATING
2024-03-26 09:07:37.441 3859-4099 Pruebas com.dji.sampleV5.aircraft D UPDATING
2024-03-26 09:07:38.442 3859-4099 Pruebas com.dji.sampleV5.aircraft D UPDATING
2024-03-26 09:07:39.442 3859-4099 Pruebas com.dji.sampleV5.aircraft D UPDATING
2024-03-26 09:07:40.442 3859-4099 Pruebas com.dji.sampleV5.aircraft D UPDATING
Actually i have four photos on my SD, but the MediaManager failed to fetch file list, saying ther are no files, but the four last numbers from message: I (co_a:124) Fetch file list failed, retCode -> 0 files -> [262169, 524313, 786457, 786473]filterNONE, seems to be the four photos i have on the SD card.
I could also say that the FileListState keeps in Updating state as long as the app. I've never seen UP_TO_DATE state before UPDATING.
Am i doing something wrong?
|
|