1e41f4b71Sopenharmony_ci# @ohos.multimedia.movingphotoview (MovingPhotoView)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **MovingPhotoView** component is used to play moving photos and control the playback status.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - This component is supported since API version 12. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> - Currently, the **MovingPhotoView** component cannot be used in Previewer.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Modules to Import
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```
13e41f4b71Sopenharmony_ciimport { MovingPhotoView, MovingPhotoViewController, MovingPhotoViewAttribute } from '@kit.MediaLibraryKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## MovingPhotoView
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci> **NOTE**
19e41f4b71Sopenharmony_ci>
20e41f4b71Sopenharmony_ci> - Currently, live attributes cannot be set.
21e41f4b71Sopenharmony_ci> - Currently, **expandSafeArea** in the ArkUI common attribute **ComponentOptions** cannot be set.
22e41f4b71Sopenharmony_ci> - When this component is long pressed to trigger playback, the component area is zoomed in to 1.1 times.
23e41f4b71Sopenharmony_ci> - This component uses [AVPlayer](../apis-media-kit/_a_v_player.md#avplayer) to play moving photos. The number of [AVPlayers](../apis-media-kit/_a_v_player.md#avplayer) being used at the same time cannot exceed three. Otherwise, frame freezing may occur during the playback.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ciMovingPhotoView(options: MovingPhotoViewOptions)
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**Parameters**
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci| Name | Type                                                 | Mandatory| Description      |
31e41f4b71Sopenharmony_ci| ------- | --------------------------------------------------------- | ---- | -------------- |
32e41f4b71Sopenharmony_ci| options | [MovingPhotoViewOptions](#movingphotoviewoptions) | Yes  | Moving photo information.|
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci## MovingPhotoViewOptions
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci| Name     | Type                                                                                        | Mandatory| Description                                                                                                                                       |
38e41f4b71Sopenharmony_ci| ----------- | ------------------------------------------------------------------------------------------------ | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
39e41f4b71Sopenharmony_ci| movingPhoto | [MovingPhoto](js-apis-photoAccessHelper.md#movingphoto12) | Yes  | **MovingPhoto** instance. For details, see [MovingPhoto](js-apis-photoAccessHelper.md#movingphoto12).|
40e41f4b71Sopenharmony_ci| controller  | [MovingPhotoViewController](#movingphotoviewcontroller)                                          | No  | Controller used to control the playback status of the moving photo.                                                                                               |
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci## Properties
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ciIn addition to the [universal properties](../apis-arkui/arkui-ts/ts-universal-attributes-size.md), the following properties are supported.
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci### muted
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_cimuted(isMuted: boolean)
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ciSets whether to mute the player.
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci**Parameters**
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci| Name | Type   | Mandatory| Description                        |
60e41f4b71Sopenharmony_ci| ------- | ------- | ---- | ---------------------------- |
61e41f4b71Sopenharmony_ci| isMuted | boolean | Yes  | Whether to mute the player.<br>Default value: **false**<br>The value **true** means to mute the player; the value **false** means the opposite. |
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci### objectFit
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ciobjectFit(value: ImageFit)
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ciSet the display mode of the moving photo.
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci**Parameters**
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci| Name| Type                                                                         | Mandatory| Description                            |
77e41f4b71Sopenharmony_ci| ------ | ----------------------------------------------------------------------------- | ---- | -------------------------------- |
78e41f4b71Sopenharmony_ci| value  | [ImageFit](../apis-arkui/arkui-ts/ts-appendix-enums.md#imagefit) | Yes  | Image scale type.<br>Default value: **Cover**|
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci### autoPlayPeriod<sup>13+</sup>
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ciautoPlayPeriod(startTime: number, endTime: number)
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ciSets the automatic play period, which is a configuration item of **autoPlay**.
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ciBefore this method is called, [autoPlay](#autoplay13) must be set to **true**. Otherwise, the specified video play period (**startTime**, **endTime**) does not take effect.
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 13.
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci**Parameters**
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci| Name | Type   | Mandatory| Description                        |
96e41f4b71Sopenharmony_ci| ------- | ------- | ---- | ---------------------------- |
97e41f4b71Sopenharmony_ci| startTime| number| Yes  | Start playback time, in ms.<br>Value range: [0, 3000]|
98e41f4b71Sopenharmony_ci| endTime| number| Yes  | End playback time, in ms.<br>Value range: [0, 3000]|
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci### autoPlay<sup>13+</sup>
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ciautoPlay(isAutoPlay: boolean)
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ciSets autoplay. After the moving photo is played once, a static image is displayed.
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 13.
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci**Parameters**
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci| Name | Type   | Mandatory| Description                        |
114e41f4b71Sopenharmony_ci| ------- | ------- | ---- | ---------------------------- |
115e41f4b71Sopenharmony_ci| isAutoPlay| boolean| Yes  | Whether to enable autoplay.<br>The value **true** means to enable autoplay; the value **false** means the opposite.<br>Default value: **false** |
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci### repeatPlay<sup>13+</sup>
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_cirepeatPlay(isRepeatPlay: boolean)
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ciSets repeated play. **repeatPlay** is mutually exclusive with **autoPlay** and **Long Press** feature, and takes precedence over **autoPlay** and **Long Press** feature.
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 13.
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**Parameters**
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci| Name | Type   | Mandatory| Description                        |
131e41f4b71Sopenharmony_ci| ------- | ------- | ---- | ---------------------------- |
132e41f4b71Sopenharmony_ci| isRepeatPlay| boolean| Yes  | Whether to enable repeated play.<br>The value **true** means to enable repeated play; the value **false** means the opposite.<br>Default value: **false** |
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci## Events
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ciIn addition to [universal events](../apis-arkui/arkui-ts/ts-universal-events-click.md), the following events are supported.
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci### onComplete<sup>13+</sup>
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_cionComplete(callback: MovingPhotoViewEventCallback)
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ciCalled when the image of a moving photo is loaded.
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 13.
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci**Parameters**
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci| Name  | Type                                                         | Mandatory| Description                          |
152e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------- | ---- | ------------------------------ |
153e41f4b71Sopenharmony_ci| callback | [MovingPhotoViewEventCallback](#movingphotovieweventcallback) | Yes  | Callback invoked when the image of a moving photo is loaded.|
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci### onStart
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_cionStart(callback: MovingPhotoViewEventCallback)
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ciCalled when the playback of a moving photo starts.
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci**Parameters**
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci| Name  | Type                                                         | Mandatory| Description                          |
169e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------- | ---- | ------------------------------ |
170e41f4b71Sopenharmony_ci| callback | [MovingPhotoViewEventCallback](#movingphotovieweventcallback) | Yes  | Callback to be invoked when a moving photo starts playing.|
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci### onPause
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_cionPause(callback: MovingPhotoViewEventCallback)
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ciCalled when the playback is paused.
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**Parameters**
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci| Name  | Type                                                         | Mandatory| Description                          |
186e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------- | ---- | ------------------------------ |
187e41f4b71Sopenharmony_ci| callback | [MovingPhotoViewEventCallback](#movingphotovieweventcallback) | Yes  | Callback to be invoked when the playback of a moving photo is paused.|
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci### onFinish
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_cionFinish(callback: MovingPhotoViewEventCallback)
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ciCalled when the playback is finished.
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci**Parameters**
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci| Name  | Type                                                         | Mandatory| Description                          |
203e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------- | ---- | ------------------------------ |
204e41f4b71Sopenharmony_ci| callback | [MovingPhotoViewEventCallback](#movingphotovieweventcallback) | Yes  | Callback to be invoked when the playback of a moving photo ends.|
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci### onError
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_cionError(callback: MovingPhotoViewEventCallback)
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ciCalled when the playback fails.
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci**Parameters**
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci| Name  | Type                                                         | Mandatory| Description                          |
220e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------- | ---- | ------------------------------ |
221e41f4b71Sopenharmony_ci| callback | [MovingPhotoViewEventCallback](#movingphotovieweventcallback) | Yes  | Callback to be invoked when the playback of a moving photo fails.|
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci### onStop
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_cionStop(callback: MovingPhotoViewEventCallback)
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ciCalled when the playback is stopped (by **stop()**).
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci**Parameters**
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci| Name  | Type                                                         | Mandatory| Description                          |
237e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------- | ---- | ------------------------------ |
238e41f4b71Sopenharmony_ci| callback | [MovingPhotoViewEventCallback](#movingphotovieweventcallback) | Yes  | Callback to be invoked when the playback of a moving photo is stopped.|
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci## MovingPhotoViewEventCallback
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_cideclare type MovingPhotoViewEventCallback = () => void
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ciDefines a callback to be invoked when the playback status of a moving photo changes.
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci## MovingPhotoViewController
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ciA **MovingPhotoViewController** object can be used to control a **MovingPhotoView** component. For details, see [@ohos.multimedia.media](../apis-media-kit/js-apis-media.md).
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci### startPlayback
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_cistartPlayback(): void
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ciStarts playback.
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci### stopPlayback
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_cistopPlayback(): void
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ciStops playback. Once started again, the playback starts from the beginning.
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci## Example
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci```ts
273e41f4b71Sopenharmony_ci// xxx.ets
274e41f4b71Sopenharmony_ciimport { photoAccessHelper } from '@kit.MediaLibraryKit';
275e41f4b71Sopenharmony_ciimport { emitter } from '@kit.BasicServicesKit';
276e41f4b71Sopenharmony_ciimport { dataSharePredicates } from '@kit.ArkData';
277e41f4b71Sopenharmony_ciimport { MovingPhotoView, MovingPhotoViewController, MovingPhotoViewAttribute } from '@kit.MediaLibraryKit';
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ciconst PHOTO_SELECT_EVENT_ID: number = 80001
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci@Entry
282e41f4b71Sopenharmony_ci@Component
283e41f4b71Sopenharmony_cistruct MovingPhotoViewDemo {
284e41f4b71Sopenharmony_ci  @State src: photoAccessHelper.MovingPhoto | undefined = undefined
285e41f4b71Sopenharmony_ci  @State isMuted: boolean = false
286e41f4b71Sopenharmony_ci  controller: MovingPhotoViewController = new MovingPhotoViewController()
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci  aboutToAppear(): void {
289e41f4b71Sopenharmony_ci    emitter.on({
290e41f4b71Sopenharmony_ci      eventId: PHOTO_SELECT_EVENT_ID,
291e41f4b71Sopenharmony_ci      priority: emitter.EventPriority.IMMEDIATE,
292e41f4b71Sopenharmony_ci    }, (eventData: emitter.EventData) => {
293e41f4b71Sopenharmony_ci      this.src = AppStorage.get<photoAccessHelper.MovingPhoto>('mv_data') as photoAccessHelper.MovingPhoto
294e41f4b71Sopenharmony_ci    })
295e41f4b71Sopenharmony_ci  }
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci  aboutToDisappear(): void {
298e41f4b71Sopenharmony_ci    emitter.off(PHOTO_SELECT_EVENT_ID)
299e41f4b71Sopenharmony_ci  }
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci  build() {
302e41f4b71Sopenharmony_ci    Column() {
303e41f4b71Sopenharmony_ci      Row() {
304e41f4b71Sopenharmony_ci        Button('PICK')
305e41f4b71Sopenharmony_ci          .margin(5)
306e41f4b71Sopenharmony_ci          .onClick(async () => {
307e41f4b71Sopenharmony_ci            let context = getContext(this)
308e41f4b71Sopenharmony_ci            try {
309e41f4b71Sopenharmony_ci              let uris: Array<string> = []
310e41f4b71Sopenharmony_ci              const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions()
311e41f4b71Sopenharmony_ci              photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE
312e41f4b71Sopenharmony_ci              photoSelectOptions.maxSelectNumber = 2
313e41f4b71Sopenharmony_ci              const photoViewPicker = new photoAccessHelper.PhotoViewPicker()
314e41f4b71Sopenharmony_ci              let photoSelectResult: photoAccessHelper.PhotoSelectResult = await photoViewPicker.select(photoSelectOptions)
315e41f4b71Sopenharmony_ci              uris = photoSelectResult.photoUris
316e41f4b71Sopenharmony_ci              if (uris[0]) {
317e41f4b71Sopenharmony_ci                this.handlePickerResult(context, uris[0], new MediaDataHandlerMovingPhoto())
318e41f4b71Sopenharmony_ci              }
319e41f4b71Sopenharmony_ci            } catch (e) {
320e41f4b71Sopenharmony_ci              console.error(`pick file failed`)
321e41f4b71Sopenharmony_ci            }
322e41f4b71Sopenharmony_ci          })
323e41f4b71Sopenharmony_ci      }
324e41f4b71Sopenharmony_ci      .alignItems(VerticalAlign.Center)
325e41f4b71Sopenharmony_ci      .justifyContent(FlexAlign.Center)
326e41f4b71Sopenharmony_ci      .height('15%')
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci      Row() {
329e41f4b71Sopenharmony_ci        Column() {
330e41f4b71Sopenharmony_ci          MovingPhotoView({
331e41f4b71Sopenharmony_ci            movingPhoto: this.src,
332e41f4b71Sopenharmony_ci            controller: this.controller
333e41f4b71Sopenharmony_ci          })
334e41f4b71Sopenharmony_ci            .width('100%')
335e41f4b71Sopenharmony_ci            .height('100%')
336e41f4b71Sopenharmony_ci            .muted(this.isMuted)
337e41f4b71Sopenharmony_ci            .autoPlay(true)
338e41f4b71Sopenharmony_ci            .repeatPlay(false)
339e41f4b71Sopenharmony_ci            .autoPlayPeriod(0, 600)
340e41f4b71Sopenharmony_ci            .objectFit(ImageFit.Cover)
341e41f4b71Sopenharmony_ci            .onComplete(() => {
342e41f4b71Sopenharmony_ci              console.log('Completed');
343e41f4b71Sopenharmony_ci            })
344e41f4b71Sopenharmony_ci            .onStart(() => {
345e41f4b71Sopenharmony_ci              console.log('onStart')
346e41f4b71Sopenharmony_ci            })
347e41f4b71Sopenharmony_ci            .onFinish(() => {
348e41f4b71Sopenharmony_ci              console.log('onFinish')
349e41f4b71Sopenharmony_ci            })
350e41f4b71Sopenharmony_ci            .onStop(() => {
351e41f4b71Sopenharmony_ci              console.log('onStop')
352e41f4b71Sopenharmony_ci            })
353e41f4b71Sopenharmony_ci            .onError(() => {
354e41f4b71Sopenharmony_ci              console.log('onError')
355e41f4b71Sopenharmony_ci            })
356e41f4b71Sopenharmony_ci        }
357e41f4b71Sopenharmony_ci      }
358e41f4b71Sopenharmony_ci      .height('70%')
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_ci      Row() {
361e41f4b71Sopenharmony_ci        Button('start')
362e41f4b71Sopenharmony_ci          .onClick(() => {
363e41f4b71Sopenharmony_ci            this.controller.startPlayback()
364e41f4b71Sopenharmony_ci          })
365e41f4b71Sopenharmony_ci          .margin(5)
366e41f4b71Sopenharmony_ci        Button('stop')
367e41f4b71Sopenharmony_ci          .onClick(() => {
368e41f4b71Sopenharmony_ci            this.controller.stopPlayback()
369e41f4b71Sopenharmony_ci          })
370e41f4b71Sopenharmony_ci          .margin(5)
371e41f4b71Sopenharmony_ci        Button('mute')
372e41f4b71Sopenharmony_ci          .onClick(() => {
373e41f4b71Sopenharmony_ci            this.isMuted = !this.isMuted
374e41f4b71Sopenharmony_ci          })
375e41f4b71Sopenharmony_ci          .margin(5)
376e41f4b71Sopenharmony_ci      }
377e41f4b71Sopenharmony_ci      .alignItems(VerticalAlign.Center)
378e41f4b71Sopenharmony_ci      .justifyContent(FlexAlign.Center)
379e41f4b71Sopenharmony_ci      .height('15%')
380e41f4b71Sopenharmony_ci    }
381e41f4b71Sopenharmony_ci  }
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci  async handlePickerResult(context: Context, uri: string, handler: photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto>): Promise<void> {
384e41f4b71Sopenharmony_ci    let uriPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
385e41f4b71Sopenharmony_ci    uriPredicates.equalTo('uri', uri)
386e41f4b71Sopenharmony_ci    let fetchOptions: photoAccessHelper.FetchOptions = {
387e41f4b71Sopenharmony_ci      fetchColumns: [],
388e41f4b71Sopenharmony_ci      predicates: uriPredicates
389e41f4b71Sopenharmony_ci    };
390e41f4b71Sopenharmony_ci    let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context)
391e41f4b71Sopenharmony_ci    let assetResult = await phAccessHelper.getAssets(fetchOptions)
392e41f4b71Sopenharmony_ci    let asset = await assetResult.getFirstObject()
393e41f4b71Sopenharmony_ci    let requestOptions: photoAccessHelper.RequestOptions = {
394e41f4b71Sopenharmony_ci      deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
395e41f4b71Sopenharmony_ci    }
396e41f4b71Sopenharmony_ci    try {
397e41f4b71Sopenharmony_ci      photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler)
398e41f4b71Sopenharmony_ci    } catch (err) {
399e41f4b71Sopenharmony_ci      console.error("request error: ", err)
400e41f4b71Sopenharmony_ci    }
401e41f4b71Sopenharmony_ci  }
402e41f4b71Sopenharmony_ci}
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ciclass MediaDataHandlerMovingPhoto implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
405e41f4b71Sopenharmony_ci  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
406e41f4b71Sopenharmony_ci    AppStorage.setOrCreate('mv_data', movingPhoto)
407e41f4b71Sopenharmony_ci    emitter.emit({
408e41f4b71Sopenharmony_ci      eventId: PHOTO_SELECT_EVENT_ID,
409e41f4b71Sopenharmony_ci      priority: emitter.EventPriority.IMMEDIATE,
410e41f4b71Sopenharmony_ci    }, {
411e41f4b71Sopenharmony_ci    })
412e41f4b71Sopenharmony_ci  }
413e41f4b71Sopenharmony_ci}
414e41f4b71Sopenharmony_ci```
415