HeadlinesBriefing favicon HeadlinesBriefing.com

HarmonyOS Video Gallery Crash Fix

DEV Community •
×

Developers working with HarmonyOS often encounter crashes when attempting to read video dimensions from the gallery. The issue arises when using `photoAccessHelper. PhotoAsset.get()` to retrieve width and height for video files, resulting in error code 14000014.

This error indicates that 'width' and 'height' are invalid keys for the standard `get` method, which only supports basic attributes like 'uri' and 'display_name'. The solution requires modifying the data retrieval strategy. Instead of calling `.get()` after fetching the asset, developers must specify the required dimensions in the `fetchColumns` array within the `FetchOptions` configuration.

By setting `fetchColumns: ['width', 'height']` during the initial query, the system retrieves the necessary metadata alongside the asset, preventing the crash. This technical adjustment is crucial for any application involving media publishing or gallery integration, ensuring stable access to video metadata within the HarmonyOS ecosystem.