Skip to main content

Multimedia Management Tutorial (Album)

1. Overview

The IAlbumManager class is used to manage aircraft albums and includes the APIs for obtaining/downloading album files or folders and canceling downloads.

2. Album API

2.1 Get Album Manager

val albumManager = DeviceManager.getDeviceManager().getFirstDroneDevice()?.getAlbumManager()

2.2 Obtaining The Album File List

/**
* Obtains the album file list.
* @param type File type [MediaTypeEnum].
* @param storageType Storage type [StorageTypeEnum].
* @param albumName Folder name. If set to null, all files will be obtained.
* @param offset Offset.
* @param count Request count.
* @param order Sorting by date modified (descending) [OrderTypeEnum].
* @param callback Callback.
*/
fun getMediaFileList(
type: MediaTypeEnum,
storageType: StorageTypeEnum,
albumName: String? = null,
offset: Int = 0,
count: Int,
order: OrderTypeEnum = OrderTypeEnum.NORMAL,
callback: CommonCallbacks.CompletionCallbackWithParam<AlbumResultBean>
)

Sample Code

albumManager.getMediaFileList(
type,
storageType,
albumName,
offset,
count,
order,
object :CommonCallbacks.CompletionCallbackWithProgressAndParam<AlbumResultBean> {
override fun onSuccess(autelAlbumBeans: AlbumResultBean?) {
}

override fun onFailure(error: IAutelCode, msg: String?) {
}
}
)

2.3 Obtaining The Album Folder List

/**
* Obtains the album folder list.
* @param storageType Storage type [StorageTypeEnum].
* @param order Sorting by date modified (descending) [OrderTypeEnum].
* @param callback Callback.
*/
fun getMediaFolderList(
storageType: StorageTypeEnum,
order: OrderTypeEnum,
callback: CommonCallbacks.CompletionCallbackWithParam<AlbumFolderResultBean>
)

Sample Code

albumManager.getMediaFolderList(storageType, sortType,
object : CommonCallbacks.CompletionCallbackWithParam<AlbumFolderResultBean> {
override fun onSuccess(t: AlbumFolderResultBean?) {
}

override fun onFailure(error: IAutelCode, msg: String?) {
}
})

2.4 Deleting Album Files/Folders

/**
* Deletes specified album files or folders.
* @param indexId File/Folder IDs.
* @param storageType Storage type.
* @param callback Deletion result.
*/
fun deleteMediaFile(
indexId: Int,
callback: CommonCallbacks.CompletionCallback
)

Sample Code

albumManager.deleteMediaFile(
indexId,
object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
}

override fun onFailure(code: IAutelCode, msg: String?) {
}
})

2.5 Download The Specified Album File

/**
* Downloads the specified album file.
* @param sourcePath Path of the files to download from.
* @param destPath Path of the files to download to.
* @param callback Download callback.
*/
fun downloadMediaFile(
sourcePath:String,
destPath:String,
callback: CommonCallbacks.DownLoadCallbackWithProgress<Double>
): BaseRequest

Sample Code

albumManager.downloadMediaFile(
sourcePath,
destPath,
object : CommonCallbacks.DownLoadCallbackWithProgress<Double> {
override fun onSuccess(file: File?) {
}

override fun onProgressUpdate(progress: Double, speed: Double) {
}

override fun onFailure(error: IAutelCode) {
}
})

2.6 Cancel Download

/***
* Cancels the download request.
* @param request Request for file download.
*/
fun cancelDownload(request: BaseRequest)

Sample Code

albumManager.cancelDownload(baseRequest)