DJI Mobile SDK Documentation

      class MediaFile

      class MediaFile implements Serializable
      Package:dji.sdk.media
      Description:

      This class contains information about a multi-media file on the SD card. It also provides methods to retrieve the data in the file.

      Class Members:
      Callback
      interface
      interface Callback
      interface Callback
      Package:dji.sdk.media
      Description:

      Tells that a new media file (photo or video) is generated.

      Interface Methods:

      Callback Method

      State
      method
      method onNewFile
      void onNewFile(@NonNull MediaFile mediaFile)
      Package:dji.sdk.media
      Description:

      Called when a new media file (photo or video) has been generated.
      In this callback method, the MediaFile instance properties getDurationInSeconds and getVideoOrientation require special consideration. The thumbnail property normally has a pointer to a UIImage of the thumbnail, but this is only available when the camera is in MEDIA_DOWNLOAD work mode. Additionally, for this instance of MediaFile, the getDurationInSeconds property is 0 and the getVideoOrientation property is LANDSCAPE.

      Input Parameters:
      @NonNull MediaFile mediaFileThe new media file.
      Identifier
      method
      method getFileName
      String getFileName()
      Package:dji.sdk.media
      Description:

      Returns the name of the media file in the SD Card.

      Return:
      StringA String instance of the name of the media file.
      method
      method isValid
      boolean isValid()
      Package:dji.sdk.media
      Description:

      true if the media file is still valid. If a media file is from the file list of the media manager, the file will become invalid after the file list is reset.

      Return:
      booleanA boolean value to check if the media file is still valid.
      method
      method getIndex
      int getIndex()
      Package:dji.sdk.media
      Description:

      Get the file index used in the camera.

      Return:
      intAn int value of the file index.
      Information
      method
      method getMediaType
      MediaType getMediaType()
      Package:dji.sdk.media
      Description:

      Returns the type of media file.

      Return:
      MediaTypeAn enum value of MediaType.
      method getQuickShotVideoType
      @Nullable
      QuickShotVideoType getQuickShotVideoType()
      Package:dji.sdk.media
      Description:

      Returns the type of QuickShot video media file. It is valid when getVideoFileType is QUICK_SHOT.

      Return:
      QuickShotVideoTypeAn enum value of QuickShotVideoType.
      method getShootPhotoMode
      ShootPhotoMode getShootPhotoMode()
      Package:dji.sdk.media
      Description:

      Returns the ShootPhotoMode of a photo. Returns null if getMediaType is MOV or MP4.

      Return:
      ShootPhotoModeAn enum value of ShootPhotoMode.
      method getPanoramaMode
      PhotoPanoramaMode getPanoramaMode()
      Package:dji.sdk.media
      Description:

      Returns the PhotoPanoramaMode of a photo. It is valid when getShootPhotoMode is PANORAMA.

      Return:
      PhotoPanoramaModeAn enum value of PhotoPanoramaMode.
      method getDownloadedSize
      long getDownloadedSize()
      Package:dji.sdk.media
      Description:

      Downloaded size in Bytes of the media file.

      Return:
      longA long value of downloaded size.
      method getFileSize
      long getFileSize()
      Package:dji.sdk.media
      Description:

      Returns the size, in bytes, of the media file.

      Return:
      longSize of media file.
      method getDateCreated
      String getDateCreated()
      Package:dji.sdk.media
      Description:

      Returns the time when the media file was created as a string in the format "yyyy-MM-dd kk:mm:ss".

      Return:
      StringA String instance of the media file created date.
      method getTimeCreated
      long getTimeCreated()
      Package:dji.sdk.media
      Description:

      Returns the time when the media file was created as a long type.

      Return:
      longA long value of the media file created date.
      Photo & Video Properties
      method
      method getDurationInSeconds
      float getDurationInSeconds()
      Package:dji.sdk.media
      Description:

      If the media file is a video, this property returns the duration of the video in seconds. Will be 0s if the media file is a photo.

      Return:
      floatMedia duration.
      method getFrameRate
      VideoFrameRate getFrameRate()
      Package:dji.sdk.media
      Description:

      Frame rate when the media file is a video.

      Return:
      VideoFrameRateAn int value.
      method getResolution
      VideoResolution getResolution()
      Package:dji.sdk.media
      Description:

      Camera resolution.

      Return:
      VideoResolutionAn enum value of VideoResolution.
      method getVideoOrientation
      Orientation getVideoOrientation()
      Package:dji.sdk.media
      Description:

      The orientation of the camera when the video file was first recorded. If the camera orientation changes during a video capture, this will report the initial orientation. Will be LANDSCAPE if the media file is a photo. Only Mavic Pro supports this property. Will be LANDSCAPE for other products.

      Return:
      OrientationAn enum value of Orientation
      Storage Location
      method
      method getStorageLocation
      StorageLocation getStorageLocation()
      Package:dji.sdk.media
      Description:

      Storage location of the media file.

      Return:
      StorageLocationAn enum value of StorageLocation.
      Video File Type
      method
      method getVideoFileType
      @Nullable
      VideoFileType getVideoFileType()
      Package:dji.sdk.media
      Description:

      Returns the type of video media file. This property is only valid when the getMediaType is MOV or MP4. Returns null for other media types.

      Return:
      VideoFileTypeAn enum value of VideoFileType.
      Custom Information
      method
      method getCustomInformation
      String getCustomInformation()
      Package:dji.sdk.media
      Description:

      Custom information can be stored in media file's XMP meta data using setMediaFileCustomInformation This property contains the information that was written to this media file. If this property returns null, use fetchCustomInformation to populate it. Only supported by Phantom 4 Pro, Phantom 4 Advanced and Inspire 2 with firmware versions from after May 23 2017.

      Return:
      StringA string value.
      Download Media
      method
      method getThumbnail
      Bitmap getThumbnail()
      Package:dji.sdk.media
      Description:

      Returns the thumbnail for this media. If this property returns nil, call fetchThumbnail.

      Return:
      BitmapA Bitmap object.
      Preview Image
      method
      method getPreview
      Bitmap getPreview()
      Package:dji.sdk.media
      Description:

      Returns the preview image for this media. If this property returns null, call fetchPreview.

      Return:
      BitmapA Bitmap object.
      Reset thumbnail
      method
      method resetThumbnail
      void resetThumbnail(@Nullable final CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      Resets the cached thumbnail to null to release the memory usage.

      Input Parameters:
      @Nullable final CompletionCallback callbackCompletion callback with the returned execution result.
      Fetch Preview
      method
      method fetchPreview
      void fetchPreview(@NonNull final CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      Fetch media's preview image. The preview image is a lower resolution (960 x 540) version of a photo. The MediaType of this media object should be JPEG or TIFF. The preview will be stored in getPreview.

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

      Resets the cached preview image to null to release the memory usage.

      Input Parameters:
      @Nullable final CompletionCallback callbackThe completion callback with the returned execution result.
      Download Custom Info
      method
      method fetchCustomInformation
      void fetchCustomInformation(@NonNull CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      Custom information can be stored in media file's XMP meta data using setMediaFileCustomInformation. The information will be stored in getCustomInformation. Only supported by Phantom 4 Pro, Phantom 4 Advanced, Phantom 4 Pro V2.0, Zenmuse X4S, Zenmuse X5S, Zenmuse X7 and Mavic 2 Enterprise camera.

      Input Parameters:
      @NonNull CompletionCallback callbackThe completion callback with the returned execution result.
      Fetch File Data
      method
      method fetchFileData
      void fetchFileData(@NonNull final File destDir,
      @Nullable String fileNameWithoutExtension,
      @NonNull final DownloadListener<String> callback)
      Package:dji.sdk.media
      Description:

      Fetches this media file's full resolution data from the SD card. The difference between fetching the media data and fetching the thumbnail is that fetching the thumbnail will return a low-resolution image of the actual picture, while fetching the media data will return all data for a video or image. If last download action is aborted, it will continue to download the data from where the file download has been aborted. Not supported by Phantom 4 RTK. Please use setHighQualityPreviewEnabled to fetch high quality preview instead.

      Input Parameters:
      @NonNull final File destDirFile instance of location to save the files, which can not be null.
      @Nullable String fileNameWithoutExtensionThe fileName to store in mobile devices, without the file extension.<br> If it is null, the file name in the camera's SDCard will be used.
      @NonNull final DownloadListener<String> callbackCompletion callback that receives the execution result.
      Stop Fetching File Data
      method
      method stopFetchingFileData
      void stopFetchingFileData (@Nullable CompletionCallback callback)
      Package:dji.sdk.media
      Description:

      Stops a currently executing call of fetchFileData.

      Input Parameters:
      @Nullable CompletionCallback callbackThe completion callback with the returned execution result.
      Fetching File Data
      method
      method fetchSubFileDataList
      void fetchSubFileDataList(@NonNull final CompletionCallbackWith<List<MediaFile>> callback)
      Package:dji.sdk.media
      Description:

      Fetches the file data of the sub media files. It is available only when getMediaType is PANORAMA or SHALLOW_FOCUS.

      Input Parameters:
      @NonNull final CompletionCallbackWith<List<MediaFile>> callbackCompletion callback that receives the execution result.
      enum MediaType
      enum MediaType
      Package:dji.sdk.media
      Description:

      Media types.

      Enum Members:
      UNKNOWNUnknown file type.
      JPEGImage of JPEG format.
      MP4Video of MP4 format.
      MOVVideo of MOV format.
      RAW_DNGImage of DNG format.
      PANORAMAPanorama file type.
      TIFFTIFF file type.
      SHALLOW_FOCUSShallowFocus file type. ShallowFocus files have a shallow depth of field.
      SEQTIFF Sequence file type. It is a video format for infrared cameras.
      TIFF_SEQSEQ file type. It is a video format for infrared cameras.
      Class Members:
      enum VideoFileType
      enum VideoFileType
      Package:dji.sdk.media
      Description:

      Video file types. It is not supported by onNewFile return MediaFile media file object.

      Enum Members:
      NORMALThe video file is recorded in normal mode.
      TIME_LAPSEThe video file is recorded in time-lapse mode.
      SLOW_MOTIONThe video file is recorded as slow motion video.
      QUICK_SHOTThe video file is recorded during a QuickShot mission. Use QUICK_SHOT to check the detail QuickShot mode of the video file.
      HYPERLAPSEThe video is recorded when the aircraft is in hyper-lapse mode. It is only supported by Mavic 2 Zoom and Mavic 2 Pro. Hyper-lapse is only supported by DJI GO 4.
      UNKNOWNUnknown.
      Class Members:
      enum QuickShotVideoType
      enum QuickShotVideoType
      Package:dji.sdk.media
      Description:

      The QuickShot modes of the video file when its type is QUICK_SHOT.

      Enum Members:
      NONEThe video file is not a QuickShot video.
      CIRCLEThe QuickShot video file is recorded in Circle mode.
      DRONIEThe QuickShot video file is recorded in Dronie mode.
      HELIXThe QuickShot video file is recorded in Helix mode.
      ROCKETThe QuickShot video file is recorded in Rocket mode.
      BOOMERANGThe QuickShot video file is recorded in Boomerang mode.
      ASTEROIDThe QuickShot video file is recorded in Asteroid mode.
      DOLLY_ZOOMThe QuickShot video file is recorded in DollyZoom mode.
      UNKNOWNUnknown.
      Class Members: