openharmony 鸿蒙 ohos-multimedia-movingphotoview-sys

2025-06-12 浏览 (1)

@ohos.multimedia.movingphotoview (MovingPhotoView) (System API)

The MovingPhotoView component is used to play moving photos and control the playback status.

NOTE

  • The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
  • This topic describes only the system APIs provided by the module. For details about its public APIs, see @ohos.multimedia.movingphotoview (MovingPhotoView).

MovingPhotoViewOptions

NameTypeMandatoryDescription
movingPhotoFormat14+PixelMapFormatNoDecoding format of the cover image of the MovingPhotoView component.
dynamicRangeMode14+DynamicRangeModeNoRange mode of the cover image of the MovingPhotoView component.

PixelMapFormat14+

Enumerates the decoding formats available for the cover image of the MovingPhotoView component.

System API: This is a system API.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
UNKNOWN0Unknown format.
RGBA_88881RGBA_8888.
NV212NV21.
RGBA_10101023RGBA_1010102.
YCBCR_P0104YCBCR_P010.
YCRCB_P0105YCRCB_P010.

DynamicRangeMode14+

Enumerates the extended range modes available for the cover image of the MovingPhotoView component. The range mode determines the image display effect.

System API: This is a system API.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
HIGH0Enables unrestricted extended range for HDR effects. The recommended decoding format is YCBCR_P010.
CONSTRAINT1Allows limited extended range for the image content.
STANDARD2Keeps the image content within the standard dynamic range for SDR effects. The recommended decoding formats are UNKNOWN and RGBA_8888.

Example: Setting the Decoding Format and Range Mode for Moving Photos in a System Application

// This example illustrates how to use the parameters. For detailed implementation, check the public API documentation for moving photos.
import { photoAccessHelper, MovingPhotoView, MovingPhotoViewController, MovingPhotoViewAttribute } from '@kit.MediaLibraryKit';
import { PixelMapFormat, DynamicRangeMode } from '@ohos.multimedia.movingphotoview';

let data: photoAccessHelper.MovingPhoto
async function loading(context: Context) {
  try {
    // Ensure that the media assets corresponding to imageFileUri and videoFileUri exist in the application sandbox directory.
    let imageFileUri = 'file://{bundleName}/data/storage/el2/base/haps/entry/files/xxx.jpg';
    let videoFileUri = 'file://{bundleName}/data/storage/el2/base/haps/entry/files/xxx.mp4';
    data = await photoAccessHelper.MediaAssetManager.loadMovingPhoto(context, imageFileUri, videoFileUri);
    console.info('load moving photo successfully');
  } catch (err) {
    console.error(`load moving photo failed with error: ${err.code}, ${err.message}`);
  }
}
@Entry
@Component
struct Index {
  controller: MovingPhotoViewController = new MovingPhotoViewController();
  format: undefined|PixelMapFormat = PixelMapFormat.YCBCR_P010;
  mode: undefined|DynamicRangeMode = DynamicRangeMode.HIGH;
  private uiContext: UIContext = this.getUIContext()
  aboutToAppear(): void {
    loading(this.uiContext.getHostContext()!)
  }

  build() {
    NavDestination() {
      Column() {
        Stack({ alignContent: Alignment.BottomStart }) {
          MovingPhotoView({
            movingPhoto: data,
            controller: this.controller,
            movingPhotoFormat: this.format,
            dynamicRangeMode: this.mode
          })
        }
      }
    }
  }
}

你可能感兴趣的鸿蒙文章

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 鸿蒙media_asset_manager_capi.h

harmony 鸿蒙MediaAssetManager

harmony 鸿蒙MediaLibrary_RequestId

harmony 鸿蒙MediaLibrary_RequestOptions

harmony 鸿蒙moving_photo_capi.h

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