openharmony 鸿蒙 capi-media-asset-manager-capi-h

2025-06-12 浏览 (1)

media_asset_manager_capi.h

Overview

The media_asset_manager_capi.h file declares the APIs of the media asset manager. You can use the functions to request media assets in the media library.

Library: libmedia_asset_manager.so

File to include: <multimedia/media_library/media_asset_manager_capi.h>

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

Since: 12

Related module: MediaAssetManager

Summary

Functions

NameDescription
OH_MediaAssetManager* OH_MediaAssetManager_Create(void)Creates an OH_MediaAssetManager instance.
MediaLibrary_RequestId OH_MediaAssetManager_RequestImageForPath(OH_MediaAssetManager* manager, const char* uri,MediaLibrary_RequestOptions requestOptions, const char* destPath, OH_MediaLibrary_OnDataPrepared callback)Requests an image in the specified directory.
MediaLibrary_RequestId OH_MediaAssetManager_RequestVideoForPath(OH_MediaAssetManager* manager, const char* uri,MediaLibrary_RequestOptions requestOptions, const char* destPath, OH_MediaLibrary_OnDataPrepared callback)Requests a video in the specified directory.
bool OH_MediaAssetManager_CancelRequest(OH_MediaAssetManager* manager, const MediaLibrary_RequestId requestId)Cancels a request based on the request ID.
MediaLibrary_ErrorCode OH_MediaAssetManager_RequestMovingPhoto(OH_MediaAssetManager* manager,OH_MediaAsset* mediaAsset, MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId,OH_MediaLibrary_OnMovingPhotoDataPrepared callback)Requests a moving photo based on different policies.
MediaLibrary_ErrorCode OH_MediaAssetManager_RequestImage(OH_MediaAssetManager* manager, OH_MediaAsset* mediaAsset,MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId,OH_MediaLibrary_OnImageDataPrepared callback)Requests an image based on different policies.
MediaLibrary_ErrorCode OH_MediaAssetManager_Release(OH_MediaAssetManager* manager)Releases an OH_MediaAssetManager instance.

Function Description

OH_MediaAssetManager_Create()

OH_MediaAssetManager* OH_MediaAssetManager_Create(void)

Description

Creates an OH_MediaAssetManager instance.

Since: 12

Return value

TypeDescription
OH_MediaAssetManager*Pointer to the OH_MediaAssetManager instance created.

OH_MediaAssetManager_RequestImageForPath()

MediaLibrary_RequestId OH_MediaAssetManager_RequestImageForPath(OH_MediaAssetManager* manager, const char* uri,MediaLibrary_RequestOptions requestOptions, const char* destPath, OH_MediaLibrary_OnDataPrepared callback)

Description

Requests an image in the specified directory.

Required permissions: ohos.permission.READ_IMAGEVIDEO

Since: 12

Parameters

ParameterDescription
OH_MediaAssetManager* managerPointer to the OH_MediaAssetManager instance.
const char* uriPointer to the URI of the requested image.
MediaLibrary_RequestOptions requestOptionsOptions related to the media asset quality and delivery mode.
const char* destPathPointer to the destination directory of the requested image.
OH_MediaLibrary_OnDataPrepared callbackCallback to be invoked when the requested image is ready.

Return value

TypeDescription
MediaLibrary_RequestIdRequest ID.

OH_MediaAssetManager_RequestVideoForPath()

MediaLibrary_RequestId OH_MediaAssetManager_RequestVideoForPath(OH_MediaAssetManager* manager, const char* uri,MediaLibrary_RequestOptions requestOptions, const char* destPath, OH_MediaLibrary_OnDataPrepared callback)

Description

Requests a video in the specified directory.

Required permissions: ohos.permission.READ_IMAGEVIDEO

Since: 12

Parameters

ParameterDescription
OH_MediaAssetManager* managerPointer to the OH_MediaAssetManager instance.
const char* uriPointer to the URI of the requested video.
MediaLibrary_RequestOptions requestOptionsOptions related to the media asset quality and delivery mode.
const char* destPathPointer to the destination directory of the requested video.
OH_MediaLibrary_OnDataPrepared callbackCallback to be invoked when the requested video is ready.

Return value

TypeDescription
MediaLibrary_RequestIdRequest ID.

OH_MediaAssetManager_CancelRequest()

bool OH_MediaAssetManager_CancelRequest(OH_MediaAssetManager* manager, const MediaLibrary_RequestId requestId)

Description

Cancels a request based on the request ID.

Required permissions: ohos.permission.READ_IMAGEVIDEO

Since: 12

Parameters

ParameterDescription
OH_MediaAssetManager* managerPointer to the OH_MediaAssetManager instance.
const MediaLibrary_RequestId requestIdID of the request to cancel.

Return value

TypeDescription
boolOperation result. The value true is returned if the request is successfully canceled, and false is returned otherwise.

OH_MediaAssetManager_RequestMovingPhoto()

MediaLibrary_ErrorCode OH_MediaAssetManager_RequestMovingPhoto(OH_MediaAssetManager* manager,OH_MediaAsset* mediaAsset, MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId,OH_MediaLibrary_OnMovingPhotoDataPrepared callback)

Description

Requests a moving photo based on different policies.

Required permissions: ohos.permission.READ_IMAGEVIDEO

Since: 13

Parameters

ParameterDescription
OH_MediaAssetManager* managerPointer to the OH_MediaAssetManager instance.
OH_MediaAsset* mediaAssetPointer to the OH_MediaAsset instance to be requested.
MediaLibrary_RequestOptions requestOptionsOptions related to the media asset quality and delivery mode. The options are specified by MediaLibrary_RequestOptions.
MediaLibrary_RequestId* requestIdRequest ID, which is specified by MediaLibrary_RequestId.
OH_MediaLibrary_OnMovingPhotoDataPrepared callbackCallback to be invoked when the requested moving photo is ready. The callback is specified by OH_MediaLibrary_OnMovingPhotoDataPrepared.

Return value

TypeDescription
MediaLibrary_ErrorCodeMEDIA_LIBRARY_OK: operation success.
MEDIA_LIBRARY_PARAMETER_ERROR: incorrect parameters. Possible causes:
1. A mandatory parameter is not specified.
2. A parameter type is incorrect.
3. Parameter verification fails.
MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED: unsupported operation.
MEDIA_LIBRARY_PERMISSION_DENIED: no access permission.
MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR: internal system error.

OH_MediaAssetManager_RequestImage()

MediaLibrary_ErrorCode OH_MediaAssetManager_RequestImage(OH_MediaAssetManager* manager, OH_MediaAsset* mediaAsset,MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId,OH_MediaLibrary_OnImageDataPrepared callback)

Description

Requests an image based on different policies.

Required permissions: ohos.permission.READ_IMAGEVIDEO

Since: 12

Parameters

ParameterDescription
OH_MediaAssetManager* managerPointer to the OH_MediaAssetManager instance.
OH_MediaAsset* mediaAssetPointer to the OH_MediaAsset instance to be requested.
MediaLibrary_RequestOptions requestOptionsOptions related to the media asset quality and delivery mode. The options are specified by MediaLibrary_RequestOptions.
MediaLibrary_RequestId* requestIdRequest ID, which is specified by MediaLibrary_RequestId.
OH_MediaLibrary_OnImageDataPrepared callbackCallback to be invoked when the requested image is ready. The callback is specified by OH_MediaLibrary_OnImageDataPrepared.

Return value

TypeDescription
MediaLibrary_ErrorCodeMEDIA_LIBRARY_OK: operation success.
MEDIA_LIBRARY_PARAMETER_ERROR: incorrect parameters. Possible causes:
1. A mandatory parameter is not specified.
2. A parameter type is incorrect.
3. Parameter verification fails.
MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED: unsupported operation.
MEDIA_LIBRARY_PERMISSION_DENIED: no access permission.
MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR: internal system error.

OH_MediaAssetManager_Release()

MediaLibrary_ErrorCode OH_MediaAssetManager_Release(OH_MediaAssetManager* manager)

Description

Releases an OH_MediaAssetManager instance.

Since: 13

Parameters

ParameterDescription
OH_MediaAssetManager* managerPointer to the OH_MediaAssetManager instance.

Return value

TypeDescription
MediaLibrary_ErrorCodeMEDIA_LIBRARY_OK: operation success.
MEDIA_LIBRARY_PARAMETER_ERROR: incorrect parameters. Possible causes:
1. A mandatory parameter is not specified.
2. A parameter type is incorrect.
3. Parameter verification fails.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Media Library Kit (Media File Management Service)

harmony 鸿蒙media_access_helper_capi.h

harmony 鸿蒙media_asset_base_capi.h

harmony 鸿蒙media_asset_capi.h

harmony 鸿蒙media_asset_change_request_capi.h

harmony 鸿蒙MediaAssetManager

harmony 鸿蒙MediaLibrary_RequestId

harmony 鸿蒙MediaLibrary_RequestOptions

harmony 鸿蒙moving_photo_capi.h

harmony 鸿蒙OH_MediaAsset

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/jOWhoR