DJI Mobile SDK Documentation

      class MediaManager

      class MediaManager implements DJIParamAccessListener
      Package:dji.sdk.media
      Description:

      The media manager is used to interact with the file system on the SD card or the internal storage. By using the media manager, the user can get the metadata for all the multimedia files, and has access to each individual multimedia file.

      Class Members:
      method addMediaUpdatedVideoPlaybackStateListener
      void addMediaUpdatedVideoPlaybackStateListener(VideoPlaybackStateListener callback)
      Package:dji.sdk.media
      Description:

      Sets the callback object for updating the video playback state of the media manager.

      Input Parameters:
      VideoPlaybackStateListener callbackcallback object of updating the vision detection state.
      method getScheduler
      FetchMediaTaskScheduler getScheduler()
      Package:dji.sdk.media
      Description:

      Fetch media task scheduler. This can be used to queue the download of the previews, thumbnails and XML custom data from multiple media files.

      Return:
      FetchMediaTaskSchedulerAn object of FetchMediaTaskScheduler.
      method getSDCardFileListState
      @NonNull
      FileListState getSDCardFileListState()
      Package:dji.sdk.media
      Description:

      The file list state of the SD card.

      Return:
      FileListStateAn enum value of FileListState.
      method getSDCardFileListSnapshot
      @Nullable
      List<MediaFile> getSDCardFileListSnapshot()
      Package:dji.sdk.media
      Description:

      Returns a copy of the current file list on the SD card. Returns null if getSDCardFileListState is reset.

      Return:
      List<MediaFile>An array of MediaFile objects.
      method getInternalStorageFileListState
      @NonNull
      FileListState getInternalStorageFileListState()
      Package:dji.sdk.media
      Description:

      The file list state of the internal storage.

      Return:
      FileListStateAn enum value of FileListState.
      method getInternalStorageFileListSnapshot
      @Nullable
      List<MediaFile> getInternalStorageFileListSnapshot()
      Package:dji.sdk.media
      Description:

      Returns a copy of the current file list on the internal storage. Returns nil if getInternalStorageFileListState is reset or unknown.

      Return:
      List<MediaFile>An array of MediaFile objects.
      method refreshFileListOfStorageLocation
      void refreshFileListOfStorageLocation(SettingsDefinitions.StorageLocation storageLocation,
      CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      Refreshes the file list of the storage. If the current state is RESET, the media manager will try to fetch the complete file list. If the current state is INCOMPLETE, the media manager will only fetch the missing list of files. If the file list is refreshed successfully, the corresponding file list state (either getSDCardFileListState or getInternalStorageFileListState) will become UP_TO_DATE.

      Input Parameters:
      SettingsDefinitions.StorageLocation storageLocationThe storage location of the file list to refresh.
      CompletionCallback callbackCompletion callback to receive the result.
      method deleteFiles
      void deleteFiles(@NonNull final List<MediaFile> files,
      final CompletionCallbackWithTwoParam<List<MediaFile>, DJICameraError> callback)
      Package:dji.sdk.media
      Description:

      Delete media files from storages. If the operation is started successfully, FileListState will become DELETING. If there is error or "failedFiles" is not empty, FileListState will become RESET.

      Input Parameters:
      @NonNull final List<MediaFile> filesA list of MediaFile objects.
      final CompletionCallbackWithTwoParam<List<MediaFile>, DJICameraError> callbackA completion callback of CompletionCallbackWithTwoParam<List<MediaFile>.
      Download
      method
      method exitMediaDownloading
      void exitMediaDownloading()
      Package:dji.sdk.media
      Description:

      This will entirely stop the downloading process and of course clean the downloading thread pool. The camera will exit the MEDIA_DOWNLOAD mode and enter the SHOOT_PHOTO mode.

      Precondition:
      The camera enters the MediaDownload mode.


      Post Condition:
      After this function invoked, the camera mode will shift to TAKEPHOTO mode.

      method addUpdateFileListStateListener
      void addUpdateFileListStateListener(@NonNull FileListStateListener listener)
      Package:dji.sdk.media
      Description:

      Start listen to the update of file list state.

      Input Parameters:
      @NonNull FileListStateListener listenerA FileListStateListener interface.
      method addUpdateStorageLocationListener
      void addUpdateStorageLocationListener(@NonNull SettingsDefinitions.StorageLocation storageLocation,
      @NonNull FileListStateListener listener)
      Package:dji.sdk.media
      Description:

      Start listen to the update of file list state.

      Input Parameters:
      @NonNull SettingsDefinitions.StorageLocation storageLocationThe storage location of the file list.
      @NonNull FileListStateListener listenerA FileListStateListener interface.
      Remove listener
      method
      method removeFileListStateCallback
      void removeFileListStateCallback(@NonNull FileListStateListener listener)
      Package:dji.sdk.media
      Description:

      Stop listen to the update of file list state.

      Input Parameters:
      @NonNull FileListStateListener listenerA FileListStateListener interface.
      Video Playback
      method
      method isVideoPlaybackSupported
      boolean isVideoPlaybackSupported()
      Package:dji.sdk.media
      Description:

      Checks if the media manager supports video playback or not. @return true if the media manager supports video playback.

      Return:
      booleantrue if the media manager supports video playback.
      method playVideoMediaFile
      void playVideoMediaFile(@NonNull MediaFile videoMediaFile, @Nullable final CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      Start video playback through MediaManager. When the media manager is playing a video, video data can be received from onReceive and playback state received from onUpdate. Video playback through MediaManager is fixed at 720p.

      Input Parameters:
      @NonNull MediaFile videoMediaFileThe video to play.
      @Nullable final CompletionCallback callbackThe execution callback with the returned execution result.
      method
      method resume
      void resume(@Nullable final CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      The media manager resumes the paused video.

      Input Parameters:
      @Nullable final CompletionCallback callbackThe execution callback with the returned execution result.
      method
      method pause
      void pause(@Nullable final CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      The media manager pauses the playing video.

      Input Parameters:
      @Nullable final CompletionCallback callbackThe execution callback with the returned execution result.
      method
      method stop
      void stop(@Nullable final CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      The media manager stops the playing video.

      Input Parameters:
      @Nullable final CompletionCallback callbackThe execution callback with the returned execution result.
      method moveToPosition
      void moveToPosition(@FloatRange(from = 0) float position, @Nullable final CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      Video playback is skipped to the new position in seconds from the start of the video.

      Input Parameters:
      @FloatRange(from = 0) float positionNew position to play in seconds from start of video. Input with precision of greater than 3 decimal places, will be rounded to 3.
      @Nullable final CompletionCallback callbackThe execution callback with the returned execution result.
      Download Media
      method
      method fetchThumbnail
      void fetchThumbnail(@Nullable final CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      Fetches this media's thumbnail with a resolution (99 x 99) from the SD card. This method can be used to fetch either a photo or a video, where the first frame of the video is the thumbnail that is fetched. It is not available if the media type is Panorama.

      Precondition:
      The camera mode is MediaDownload mode.

      Post Condition:
      This method will start to download the media thumbnail in the SD card. The content can be videos or images.

      Input Parameters:
      @Nullable final CompletionCallback callbackThe completion callback with the returned execution result.
      enum FileListState
      enum FileListState
      Package:dji.sdk.media
      Description:

      States of the file list in MediaManager.

      Enum Members:
      UP_TO_DATEThe file list is up-to-date: it is synchronized with the SD card in the aircraft.
      INCOMPLETENew files have been generated since the last call of refreshFileListOfStorageLocation. Calling refreshFileListOfStorageLocation can synchronize the newly generated files and append them to the end of the file list.
      RESETThe file list is reset. The file list will be reset in one of the following cases:
      - Camera is disconnected.
      - SD card is formatted.
      - SD card is not inserted.
      - Error occurs when deleting files from SD card.
      In this state, getSDCardFileListSnapshot will return null.
      DELETINGdeleteFiles has been called and the operation is still in progress.
      RENAMINGA renaming operation is in progress.
      SYNCINGThe media manager is synchronizing the file list from the SD card.
      UNKNOWNUnknown.
      Class Members:
      State Updates
      interface
      interface VideoPlaybackStateListener
      interface VideoPlaybackStateListener
      Package:dji.sdk.media
      Description:

      Updates the video playback state of the media manager. This update method will only be called when the media manager is playing a video.

      Interface Methods:

      Callback Method

      State
      method
      method onUpdate
      void onUpdate(VideoPlaybackState videoPlaybackState)
      Package:dji.sdk.media
      Description:

      Updates the video playback state of the media manager. This update method will only be called when the media manager is playing a video.

      Input Parameters:
      VideoPlaybackState videoPlaybackStateVideoPlaybackState object.
      interface DownloadListener
      interface DownloadListener<E>
      Package:dji.sdk.media
      Description:

      This callback will notify the app when the media download executed.

      Interface Methods:

      Callback Method

      State
      method
      method onStart
      void onStart()
      Package:dji.sdk.media
      Description:

      Called when the file download begins.

      method onRateUpdate
      void onRateUpdate(long total, long current, long persize)
      Package:dji.sdk.media
      Description:

      Called to show the download rate. It is called every 1 second. Hence, the persize which is the download size among two calls is the download rate.

      Input Parameters:
      long totalThe total size.
      long currentThe current download size.
      long persizeThe download size between two calls.
      method onProgress
      void onProgress(long total, long current)
      Package:dji.sdk.media
      Description:

      Called to update the download progress. It is called every time there is data received.

      Input Parameters:
      long totalThe total size of the file being downloaded.
      long currentThe current download data size.
      method
      method onSuccess
      void onSuccess(E data)
      Package:dji.sdk.media
      Description:

      Called when the media download is completed.

      Input Parameters:
      E dataThe media that was successfully downloaded
      method
      method onFailure
      void onFailure(DJIError error)
      Package:dji.sdk.media
      Description:

      Called when the media download failed.

      Input Parameters:
      DJIError errorThe error information.
      interface FileListStateListener
      interface FileListStateListener
      Package:dji.sdk.media
      Description:

      Received file list state of the media manager.

      Interface Methods:

      Callback Method

      method onFileListStateChange
      void onFileListStateChange(FileListState state)
      Package:dji.sdk.media
      Description:

      Updates the file list state of the media manager.

      Input Parameters:
      FileListState stateThe new file list state.
      Media
      class
      Video Playback
      class