harmony 鸿蒙Media Library Kit Changelog
Media Library Kit Changelog
cl.medialibrary.1 Changed the Behavior of Certain APIs in @ohos.file.photoAccessHelper
Access Level
Public API
Reason for Change
To make the asset storage logic clearer, the mappings between assets and albums in the media library are modified. Previously, an image or video can exist in multiple logical albums through mapping, but now each photo can belong to only one physical album.
Change Impact
This change is a non-compatible change.
Adding assets to an album with addAssets
Before: The assets obtained from query are directly added.
After: A copy of the asset is added.
Removing assets from an album with removeAssets
Before: The mapping between the album and asset is removed.
After: The asset is moved to the recycle bin.
Setting the album name with setAlbumName and commitModify
Before: The album_name attribute of the album is directly changed.
After: The album is deleted, and a new one with the same metadata is created with the new name.
Registering a listener for the specified URI with registerChange
Before: The listener is registered for the asset URI obtained from query, and notifications are sent to that asset URI for any additions, deletions, or modifications.
After: Operations such as Add and Remove are performed on the copies. Therefore, notifications are sent to the copy URI.
Start API Level
10 and API 11
Change Since
OpenHarmony 5.0.0.43
Key API/Component Changes
Adding assets to an album: addAssets(assets: Array<PhotoAsset>): void
Removing assets from an album: removeAssets(assets: Array<PhotoAsset>): void
Setting the album name:
setAlbumName(name: string):void,
commitModify(callback: AsyncCallback<void>): void
- Registering a listener for a specified URI: registerChange(uri: string, forChildUris: boolean, callback: Callback<ChangeData>): void
Adaptation Guide
The API usage does not change, and no additional adaptation is required during API calls. However, since the API behavior changes, you should pay attention to the changes and make appropriate adjustments.
When addAssets is used to add a photo, the copy instead of the original photo is added to the album. Any subsequent operations on the asset should be performed on the copied asset within the album.
When using removeAssets, note that the asset is moved to the recycle bin.
When using deleteAlbums, note that all assets within the album are moved to the recycle bin.
When renaming an album with setAlbumName and commitModify, the original album is deleted and a new one is created. To continue working with the album, you should perform operations on the new album. After renaming, call getAlbums to obtain the new album name for subsequent operations.
When using registerChange, note that you will receive notifications for the addition of copied assets when addAssets is called, deletion notifications for assets within the album when removeAssets and deleteAlbums are called, and update notifications for the album when setAlbumName and commitModify are called.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Ability Framework Changelog
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
7、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦