• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (C) 2021 Huawei Device Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16import { ErrorCallback, AsyncCallback, Callback } from './@ohos.base';
17import audio from "./@ohos.multimedia.audio";
18
19/**
20 * @name media
21 * @since 6
22 */
23declare namespace media {
24  /**
25   * Creates an AVPlayer instance.
26   * @since 9
27   * @syscap SystemCapability.Multimedia.Media.AVPlayer
28   * @param callback Callback used to return AVPlayer instance if the operation is successful; returns null otherwise.
29   * @throws { BusinessError } 5400101 - No memory. Return by callback.
30   */
31   function createAVPlayer(callback: AsyncCallback<AVPlayer>): void;
32
33  /**
34   * Creates an AVPlayer instance.
35   * @since 9
36   * @syscap SystemCapability.Multimedia.Media.AVPlayer
37   * @returns A Promise instance used to return AVPlayer instance if the operation is successful; returns null otherwise.
38   * @throws { BusinessError } 5400101 - No memory. Return by promise.
39   */
40   function createAVPlayer() : Promise<AVPlayer>;
41
42  /**
43   * Creates an AVRecorder instance.
44   * @since 9
45   * @syscap SystemCapability.Multimedia.Media.AVRecorder
46   * @param callback Callback used to return AVRecorder instance if the operation is successful; returns null otherwise.
47   * @throws { BusinessError } 5400101 - No memory. Return by callback.
48   */
49  function createAVRecorder(callback: AsyncCallback<AVRecorder>): void;
50
51   /**
52    * Creates an AVRecorder instance.
53    * @since 9
54    * @syscap SystemCapability.Multimedia.Media.AVRecorder
55    * @returns A Promise instance used to return AVRecorder instance if the operation is successful; returns null otherwise.
56    * @throws { BusinessError } 5400101 - No memory. Return by promise.
57    */
58  function createAVRecorder() : Promise<AVRecorder>;
59
60  /**
61   * Creates an AudioPlayer instance.
62   * @since 6
63   * @syscap SystemCapability.Multimedia.Media.AudioPlayer
64   * @returns Returns an AudioPlayer instance if the operation is successful; returns null otherwise.
65   * @deprecated since 9
66   * @useinstead ohos.multimedia.media/media#createAVPlayer
67   */
68  function createAudioPlayer(): AudioPlayer;
69
70  /**
71   * Creates an AudioRecorder instance.
72   * @since 6
73   * @syscap SystemCapability.Multimedia.Media.AudioRecorder
74   * @returns Returns an AudioRecorder instance if the operation is successful; returns null otherwise.
75   * @deprecated since 9
76   * @useinstead ohos.multimedia.media/media#createAVRecorder
77   */
78  function createAudioRecorder(): AudioRecorder;
79
80  /**
81   * Creates an VideoPlayer instance.
82   * @since 8
83   * @syscap SystemCapability.Multimedia.Media.VideoPlayer
84   * @param callback Callback used to return AudioPlayer instance if the operation is successful; returns null otherwise.
85   * @deprecated since 9
86   * @useinstead ohos.multimedia.media/media#createAVPlayer
87   */
88  function createVideoPlayer(callback: AsyncCallback<VideoPlayer>): void;
89
90  /**
91   * Creates an VideoPlayer instance.
92   * @since 8
93   * @syscap SystemCapability.Multimedia.Media.VideoPlayer
94   * @returns A Promise instance used to return VideoPlayer instance if the operation is successful; returns null otherwise.
95   * @deprecated since 9
96   * @useinstead ohos.multimedia.media/media#createAVPlayer
97   */
98  function createVideoPlayer() : Promise<VideoPlayer>;
99
100  /**
101   * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder
102   * Creates an VideoRecorder instance.
103   * @since 9
104   * @syscap SystemCapability.Multimedia.Media.VideoRecorder
105   * @param callback Callback used to return AudioPlayer instance if the operation is successful; returns null otherwise.
106   * @throws { BusinessError } 5400101 - No memory. Return by callback.
107   * @systemapi
108   */
109  function createVideoRecorder(callback: AsyncCallback<VideoRecorder>): void;
110
111  /**
112   * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder
113   * Creates an VideoRecorder instance.
114   * @since 9
115   * @syscap SystemCapability.Multimedia.Media.VideoRecorder
116   * @returns A Promise instance used to return VideoRecorder instance if the operation is successful; returns null otherwise.
117   * @throws { BusinessError } 5400101 - No memory. Return by promise.
118   * @systemapi
119   */
120  function createVideoRecorder(): Promise<VideoRecorder>;
121
122  /**
123   * Enumerates state change reason.
124   * @since 9
125   * @syscap SystemCapability.Multimedia.Media.Core
126   */
127   enum StateChangeReason {
128    /**
129     * State changed by user operation.
130     * @since 9
131     * @syscap SystemCapability.Multimedia.Media.Core
132     */
133    USER = 1,
134
135    /**
136     * State changed by background action.
137     * @since 9
138     * @syscap SystemCapability.Multimedia.Media.Core
139     */
140    BACKGROUND = 2,
141  }
142
143 /**
144   * Enumerates ErrorCode types, return in BusinessError::code.
145   * @since 9
146   * @syscap SystemCapability.Multimedia.Media.Core
147   */
148 enum AVErrorCode {
149  /**
150   * Operation success.
151   * @since 9
152   * @syscap SystemCapability.Multimedia.Media.Core
153   */
154  AVERR_OK = 0,
155
156  /**
157   * Permission denied.
158   * @since 9
159   * @syscap SystemCapability.Multimedia.Media.Core
160   */
161  AVERR_NO_PERMISSION = 201,
162
163  /**
164   * Invalid parameter.
165   * @since 9
166   * @syscap SystemCapability.Multimedia.Media.Core
167   */
168  AVERR_INVALID_PARAMETER = 401,
169
170  /**
171   * The api is not supported in the current version.
172   * @since 9
173   * @syscap SystemCapability.Multimedia.Media.Core
174   */
175  AVERR_UNSUPPORT_CAPABILITY = 801,
176
177  /**
178   * The system memory is insufficient or the number of services reaches the upper limit.
179   * @since 9
180   * @syscap SystemCapability.Multimedia.Media.Core
181   */
182  AVERR_NO_MEMORY = 5400101,
183
184  /**
185   * Current status does not allow or do not have permission to perform this operation.
186   * @since 9
187   * @syscap SystemCapability.Multimedia.Media.Core
188   */
189  AVERR_OPERATE_NOT_PERMIT = 5400102,
190
191  /**
192   * Data flow exception information.
193   * @since 9
194   * @syscap SystemCapability.Multimedia.Media.Core
195   */
196  AVERR_IO = 5400103,
197
198  /**
199   * System or network response timeout.
200   * @since 9
201   * @syscap SystemCapability.Multimedia.Media.Core
202   */
203  AVERR_TIMEOUT = 5400104,
204
205  /**
206   * Service process died.
207   * @since 9
208   * @syscap SystemCapability.Multimedia.Media.Core
209   */
210  AVERR_SERVICE_DIED = 5400105,
211
212  /**
213   * Unsupported media format.
214   * @since 9
215   * @syscap SystemCapability.Multimedia.Media.Core
216   */
217  AVERR_UNSUPPORT_FORMAT = 5400106,
218 }
219
220  enum VideoRecorderQualityLevel {
221    /**
222     * Quality level corresponding to the lowest available resolution.
223     * @since 10
224     */
225    RECORDER_QUALITY_LOW = 0,
226
227    /**
228    * Quality level corresponding to the highest available resolution.
229    * @since 10
230    */
231    RECORDER_QUALITY_HIGH = 1,
232
233    /**
234    * Quality level corresponding to the qcif (176 x 144) resolution.
235    * @since 10
236    */
237    RECORDER_QUALITY_QCIF = 2,
238
239    /**
240    * Quality level corresponding to the cif (352 x 288) resolution.
241    * @since 10
242    */
243    RECORDER_QUALITY_CIF = 3,
244
245    /**
246    * Quality level corresponding to the 480p (720 x 480) resolution.
247    * @since 10
248    */
249    RECORDER_QUALITY_480P = 4,
250
251    /**
252    * Quality level corresponding to the 720P (1280 x 720) resolution.
253    * @since 10
254    */
255    RECORDER_QUALITY_720P = 5,
256
257    /**
258    * Quality level corresponding to the 1080P (1920 x 1080) resolution.
259    * @since 10
260    */
261    RECORDER_QUALITY_1080P = 6,
262
263    /**
264    * Quality level corresponding to the QVGA (320x240) resolution.
265    * @since 10
266    */
267    RECORDER_QUALITY_QVGA = 7,
268
269    /**
270    * Quality level corresponding to the 2160p (3840x2160) resolution.
271    * @since 10
272    */
273    RECORDER_QUALITY_2160P = 8,
274
275    /**
276    * Time lapse quality level corresponding to the lowest available resolution.
277    * @since 10
278    */
279    RECORDER_QUALITY_TIME_LAPSE_LOW = 100,
280
281    /**
282    * Time lapse quality level corresponding to the highest available resolution.
283    * @since 10
284    */
285    RECORDER_QUALITY_TIME_LAPSE_HIGH = 101,
286
287    /**
288    * Time lapse quality level corresponding to the qcif (176 x 144) resolution.
289    * @since 10
290    */
291    RECORDER_QUALITY_TIME_LAPSE_QCIF = 102,
292
293    /**
294    * Time lapse quality level corresponding to the cif (352 x 288) resolution.
295    * @since 10
296    */
297    RECORDER_QUALITY_TIME_LAPSE_CIF = 103,
298
299    /**
300    * Time lapse quality level corresponding to the 480p (720 x 480) resolution.
301    * @since 10
302    */
303    RECORDER_QUALITY_TIME_LAPSE_480P = 104,
304
305    /**
306    * Time lapse quality level corresponding to the 720p (1280 x 720) resolution.
307    * @since 10
308    */
309    RECORDER_QUALITY_TIME_LAPSE_720P = 105,
310
311    /**
312    * Time lapse quality level corresponding to the 1080p (1920 x 1088) resolution.
313    * @since 10
314    */
315    RECORDER_QUALITY_TIME_LAPSE_1080P = 106,
316
317    /**
318    * Time lapse quality level corresponding to the QVGA (320 x 240) resolution.
319    * @since 10
320    */
321    RECORDER_QUALITY_TIME_LAPSE_QVGA = 107,
322
323    /**
324    * Time lapse quality level corresponding to the 2160p (3840 x 2160) resolution.
325    * @since 10
326    */
327    RECORDER_QUALITY_TIME_LAPSE_2160P = 108,
328
329    /**
330    * High speed ( >= 100fps) quality level corresponding to the lowest available resolution.
331    * @since 10
332    */
333    RECORDER_QUALITY_HIGH_SPEED_LOW = 200,
334
335    /**
336    * High speed ( >= 100fps) quality level corresponding to the highest available resolution.
337    * @since 10
338    */
339    RECORDER_QUALITY_HIGH_SPEED_HIGH = 201,
340
341    /**
342    * High speed ( >= 100fps) quality level corresponding to the 480p (720 x 480) resolution.
343    * @since 10
344    */
345    RECORDER_QUALITY_HIGH_SPEED_480P = 202,
346
347    /**
348    * High speed ( >= 100fps) quality level corresponding to the 720p (1280 x 720) resolution.
349    * @since 10
350    */
351    RECORDER_QUALITY_HIGH_SPEED_720P = 203,
352
353    /**
354    * High speed ( >= 100fps) quality level corresponding to the 1080p (1920 x 1080 or 1920x1088)
355    * resolution.
356    * @since 10
357    */
358    RECORDER_QUALITY_HIGH_SPEED_1080P = 204,
359  }
360
361  /**
362   * Describes AVPlayer states.
363   * @since 9
364   * @syscap SystemCapability.Multimedia.Media.AVPlayer
365   */
366   type AVPlayerState = 'idle' | 'initialized' | 'prepared' | 'playing' | 'paused' | 'completed' | 'stopped' | 'released' | 'error';
367
368   /**
369    * Manages and plays media. Before calling an AVPlayer method, you must use createAVPlayer()
370    * to create an AVPlayer instance.
371    * @since 9
372    * @syscap SystemCapability.Multimedia.Media.AVPlayer
373    */
374  interface AVPlayer {
375    /**
376     * Prepare audio/video playback, it will request resource for playing.
377     * @since 9
378     * @syscap SystemCapability.Multimedia.Media.AVPlayer
379     * @param callback A callback instance used to return when prepare completed.
380     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
381     * @throws { BusinessError } 5400106 - Unsupport format. Return by callback.
382     */
383    prepare(callback: AsyncCallback<void>): void;
384
385    /**
386     * Prepare audio/video playback, it will request resource for playing.
387     * @since 9
388     * @syscap SystemCapability.Multimedia.Media.AVPlayer
389     * @returns A Promise instance used to return when prepare completed.
390     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
391     * @throws { BusinessError } 5400106 - Unsupport format. Return by promise.
392     */
393    prepare(): Promise<void>;
394
395    /**
396     * Play audio/video playback.
397     * @since 9
398     * @syscap SystemCapability.Multimedia.Media.AVPlayer
399     * @param callback A callback instance used to return when play completed.
400     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
401     */
402    play(callback: AsyncCallback<void>): void;
403
404    /**
405     * Play audio/video playback.
406     * @since 9
407     * @syscap SystemCapability.Multimedia.Media.AVPlayer
408     * @returns A Promise instance used to return when play completed.
409     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
410     */
411    play(): Promise<void>;
412
413    /**
414     * Pause audio/video playback.
415     * @since 9
416     * @syscap SystemCapability.Multimedia.Media.AVPlayer
417     * @param callback A callback instance used to return when pause completed.
418     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
419     */
420    pause(callback: AsyncCallback<void>): void;
421
422    /**
423     * Pause audio/video playback.
424     * @since 9
425     * @syscap SystemCapability.Multimedia.Media.AVPlayer
426     * @returns A Promise instance used to return when pause completed.
427     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
428     */
429    pause(): Promise<void>;
430
431    /**
432     * Stop audio/video playback.
433     * @since 9
434     * @syscap SystemCapability.Multimedia.Media.AVPlayer
435     * @param callback A callback instance used to return when stop completed.
436     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
437     */
438    stop(callback: AsyncCallback<void>): void;
439
440     /**
441      * Stop audio/video playback.
442      * @since 9
443      * @syscap SystemCapability.Multimedia.Media.AVPlayer
444      * @returns A Promise instance used to return when stop completed.
445      * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
446      */
447    stop(): Promise<void>;
448
449    /**
450     * Reset AVPlayer, it will to idle state and can set src again.
451     * @since 9
452     * @syscap SystemCapability.Multimedia.Media.AVPlayer
453     * @param callback A callback instance used to return when reset completed.
454     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
455     */
456    reset(callback: AsyncCallback<void>): void;
457
458    /**
459     * Reset AVPlayer, it will to idle state and can set src again.
460     * @since 9
461     * @syscap SystemCapability.Multimedia.Media.AVPlayer
462     * @returns A Promise instance used to return when reset completed.
463     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
464     */
465    reset(): Promise<void>;
466
467    /**
468     * Releases resources used for AVPlayer.
469     * @since 9
470     * @syscap SystemCapability.Multimedia.Media.AVPlayer
471     * @param callback A callback instance used to return when release completed.
472     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
473     */
474    release(callback: AsyncCallback<void>): void;
475
476    /**
477     * Releases resources used for AVPlayer.
478     * @since 9
479     * @syscap SystemCapability.Multimedia.Media.AVPlayer
480     * @returns A Promise instance used to return when release completed.
481     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
482     */
483    release(): Promise<void>;
484
485    /**
486     * Jumps to the specified playback position.
487     * @since 9
488     * @syscap SystemCapability.Multimedia.Media.AVPlayer
489     * @param timeMs Playback position to jump, should be in [0, duration].
490     * @param mode See @SeekMode .
491     */
492    seek(timeMs: number, mode?:SeekMode): void;
493
494    /**
495     * Sets the volume.
496     * @since 9
497     * @syscap SystemCapability.Multimedia.Media.AVPlayer
498     * @param volume Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%).
499     */
500    setVolume(volume: number): void;
501
502    /**
503     * Get all track infos in MediaDescription, should be called after data loaded callback.
504     * @since 9
505     * @syscap SystemCapability.Multimedia.Media.AVPlayer
506     * @param callback Async callback return track info in MediaDescription.
507     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
508     */
509    getTrackDescription(callback: AsyncCallback<Array<MediaDescription>>): void;
510
511    /**
512     * Get all track infos in MediaDescription, should be called after data loaded callback.
513     * @since 9
514     * @syscap SystemCapability.Multimedia.Media.AVPlayer
515     * @returns A Promise instance used to return the track info in MediaDescription.
516     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
517     */
518    getTrackDescription() : Promise<Array<MediaDescription>>;
519
520    /**
521     * Media URI. Mainstream media formats are supported.
522     * Network:http://xxx
523     * @since 9
524     * @syscap SystemCapability.Multimedia.Media.AVPlayer
525     */
526    url ?: string;
527
528    /**
529     * Media file descriptor. Mainstream media formats are supported.
530     * @since 9
531     * @syscap SystemCapability.Multimedia.Media.AVPlayer
532     */
533    fdSrc ?: AVFileDescriptor;
534
535    /**
536     * DataSource descriptor. Mainstream media formats are supported.
537     * @since 10
538     * @syscap SystemCapability.Multimedia.Media.AVPlayer
539     */
540    dataSrc ?: DataSrcDescriptor;
541
542    /**
543     * Whether to loop media playback.
544     * @since 9
545     * @syscap SystemCapability.Multimedia.Media.AVPlayer
546     */
547    loop: boolean;
548
549    /**
550     * Describes audio interrupt mode, refer to {@link #audio.InterruptMode}. If it is not
551     * set, the default mode will be used. Set it before calling the {@link #play()} in the
552     * first time in order for the interrupt mode to become effective thereafter.
553     * @since 9
554     * @syscap SystemCapability.Multimedia.Media.AVPlayer
555     */
556    audioInterruptMode ?: audio.InterruptMode;
557
558    /**
559     * Describes audio renderer info, refer to {@link #audio.AudioRendererInfo}. Set it before
560     * calling the {@link #prepare()} in the first time in order for the audio renderer info to
561     * become effective thereafter.
562     * @since 10
563     * @syscap SystemCapability.Multimedia.Media.AVPlayer
564     */
565    audioRendererInfo ?: audio.AudioRendererInfo;
566
567    /**
568     * Obtains the current audio effect mode, refer to {@link #audio.AudioEffectMode}.
569     * @since 10
570     * @syscap SystemCapability.Multimedia.Media.AVPlayer
571     */
572     audioEffectMode ?: audio.AudioEffectMode;
573
574    /**
575     * Current playback position.
576     * @since 9
577     * @syscap SystemCapability.Multimedia.Media.AVPlayer
578     */
579    readonly currentTime: number;
580
581    /**
582     * Playback duration, When the data source does not support seek, it returns - 1, such as a live broadcast scenario.
583     * @since 9
584     * @syscap SystemCapability.Multimedia.Media.AVPlayer
585     */
586    readonly duration: number;
587
588    /**
589     * Playback state.
590     * @since 9
591     * @syscap SystemCapability.Multimedia.Media.AVPlayer
592     */
593    readonly state: AVPlayerState;
594
595    /**
596     * Video player will use this id get a surface instance.
597     * @since 9
598     * @syscap SystemCapability.Multimedia.Media.AVPlayer
599     */
600    surfaceId ?: string;
601
602    /**
603     * Video width, valid after prepared.
604     * @since 9
605     * @syscap SystemCapability.Multimedia.Media.AVPlayer
606     */
607    readonly width: number;
608
609    /**
610     * Video height, valid after prepared.
611     * @since 9
612     * @syscap SystemCapability.Multimedia.Media.AVPlayer
613     */
614    readonly height: number;
615
616    /**
617     * Video scale type. By default, the {@link #VIDEO_SCALE_TYPE_FIT_CROP} will be used, for more
618     * information, refer to {@link #VideoScaleType} .
619     * @since 9
620     * @syscap SystemCapability.Multimedia.Media.AVPlayer
621     */
622    videoScaleType ?: VideoScaleType;
623
624    /**
625     * Set payback speed.
626     * @since 9
627     * @syscap SystemCapability.Multimedia.Media.AVPlayer
628     * @param speed playback speed, see @PlaybackSpeed .
629     */
630    setSpeed(speed: PlaybackSpeed): void;
631
632    /**
633     * select a specified bitrate to playback, only valid for HLS protocol network stream. By default, the
634     * player will select the appropriate bitrate according to the network connection speed. The
635     * available bitrate list reported by {@link #on('availableBitrates')}. Set it to select
636     * a specified bitrate. If the specified bitrate is not in the list of available bitrate, the player
637     * will select the minimal and closest one from the available bitrate list.
638     * @since 9
639     * @syscap SystemCapability.Multimedia.Media.AVPlayer
640     * @param bitrate the playback bitrate must be expressed in bits per second.
641     */
642    setBitrate(bitrate: number): void;
643
644    /**
645     * Register or unregister listens for media playback events.
646     * @since 9
647     * @syscap SystemCapability.Multimedia.Media.AVPlayer
648     * @param type Type of the playback event to listen for.
649     * @param callback Callback used to listen for the playback stateChange event.
650     */
651    on(type: 'stateChange', callback: (state: AVPlayerState, reason: StateChangeReason) => void): void;
652    off(type: 'stateChange'): void;
653    /**
654     * Register or unregister listens for media playback events.
655     * @since 9
656     * @syscap SystemCapability.Multimedia.Media.AVPlayer
657     * @param type Type of the playback event to listen for.
658     * @param callback Callback used to listen for the playback volume event.
659     */
660    on(type: 'volumeChange', callback: Callback<number>): void;
661    off(type: 'volumeChange'): void;
662    /**
663     * Register or unregister listens for media playback events.
664     * @since 9
665     * @syscap SystemCapability.Multimedia.Media.AVPlayer
666     * @param type Type of the playback event to listen for.
667     * @param callback Callback used to listen for the playback end of stream
668     */
669    on(type: 'endOfStream', callback: Callback<void>): void;
670    off(type: 'endOfStream'): void;
671    /**
672     * Register or unregister listens for media playback events.
673     * @since 9
674     * @syscap SystemCapability.Multimedia.Media.AVPlayer
675     * @param type Type of the playback event to listen for.
676     * @param callback Callback used to listen for the playback seekDone event.
677     */
678    on(type: 'seekDone', callback: Callback<number>): void;
679    off(type: 'seekDone'): void;
680    /**
681     * Register or unregister listens for media playback events.
682     * @since 9
683     * @syscap SystemCapability.Multimedia.Media.AVPlayer
684     * @param type Type of the playback event to listen for.
685     * @param callback Callback used to listen for the playback speedDone event.
686     */
687    on(type: 'speedDone', callback: Callback<number>): void;
688    off(type: 'speedDone'): void;
689    /**
690     * Register or unregister listens for media playback events.
691     * @since 9
692     * @syscap SystemCapability.Multimedia.Media.AVPlayer
693     * @param type Type of the playback event to listen for.
694     * @param callback Callback used to listen for the playback setBitrateDone event.
695     */
696    on(type: 'bitrateDone', callback: Callback<number>): void;
697    off(type: 'bitrateDone'): void;
698    /**
699     * Register or unregister listens for media playback events.
700     * @since 9
701     * @syscap SystemCapability.Multimedia.Media.AVPlayer
702     * @param type Type of the playback event to listen for.
703     * @param callback Callback used to listen for the playback timeUpdate event.
704     */
705    on(type: 'timeUpdate', callback: Callback<number>): void;
706    off(type: 'timeUpdate'): void;
707    /**
708     * Register or unregister listens for media playback events.
709     * @since 9
710     * @syscap SystemCapability.Multimedia.Media.AVPlayer
711     * @param type Type of the playback event to listen for.
712     * @param callback Callback used to listen for the playback durationUpdate event.
713     */
714    on(type: 'durationUpdate', callback: Callback<number>): void;
715    off(type: 'durationUpdate'): void;
716    /**
717     * Register or unregister listens for video playback buffering events.
718     * @since 9
719     * @syscap SystemCapability.Multimedia.Media.AVPlayer
720     * @param type Type of the playback buffering update event to listen for.
721     * @param callback Callback used to listen for the buffering update event, return BufferingInfoType and the value.
722     */
723    on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void;
724    off(type: 'bufferingUpdate'): void;
725    /**
726     * Register or unregister listens for start render video frame events.
727     * @since 9
728     * @syscap SystemCapability.Multimedia.Media.AVPlayer
729     * @param type Type of the playback event to listen for.
730     * @param callback Callback used to listen for the playback event return .
731     */
732    on(type: 'startRenderFrame', callback: Callback<void>): void;
733    off(type: 'startRenderFrame'): void;
734    /**
735     * Register or unregister listens for video size change event.
736     * @since 9
737     * @syscap SystemCapability.Multimedia.Media.AVPlayer
738     * @param type Type of the playback event to listen for.
739     * @param callback Callback used to listen for the playback event return video size.
740     */
741    on(type: 'videoSizeChange', callback: (width: number, height: number) => void): void;
742    off(type: 'videoSizeChange'): void;
743    /**
744     * Register or unregister listens for audio interrupt event, refer to {@link #audio.InterruptEvent}
745     * @since 9
746     * @syscap SystemCapability.Multimedia.Media.AVPlayer
747     * @param type Type of the playback event to listen for.
748     * @param callback Callback used to listen for the playback event return audio interrupt info.
749     */
750    on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void;
751    off(type: 'audioInterrupt'): void;
752    /**
753     * Register or unregister listens for available bitrate list collect completed events for HLS protocol stream playback.
754     * This event will be reported after the {@link #prepare} called.
755     * @since 9
756     * @syscap SystemCapability.Multimedia.Media.AVPlayer
757     * @param type Type of the playback event to listen for.
758     * @param callback Callback used to listen for the playback event return available bitrate list.
759     */
760    on(type: 'availableBitrates', callback: (bitrates: Array<number>) => void): void;
761    off(type: 'availableBitrates'): void;
762    /**
763     * Register or unregister listens for playback error events.
764     * @since 9
765     * @syscap SystemCapability.Multimedia.Media.AVPlayer
766     * @param type Type of the playback error event to listen for.
767     * @param callback Callback used to listen for the playback error event.
768     * @throws { BusinessError } 201 - Permission denied.
769     * @throws { BusinessError } 401 - The parameter check failed.
770     * @throws { BusinessError } 801 - Capability not supported.
771     * @throws { BusinessError } 5400101 - No memory.
772     * @throws { BusinessError } 5400102 - Operation not allowed.
773     * @throws { BusinessError } 5400103 - I/O error.
774     * @throws { BusinessError } 5400104 - Time out.
775     * @throws { BusinessError } 5400105 - Service died.
776     * @throws { BusinessError } 5400106 - Unsupport format.
777     */
778    on(type: 'error', callback: ErrorCallback): void;
779    off(type: 'error'): void;
780  }
781
782  /**
783   * Enumerates ErrorCode types, return in BusinessError::code
784   * @since 8
785   * @syscap SystemCapability.Multimedia.Media.Core
786   */
787  enum MediaErrorCode {
788    /**
789     * operation success.
790     * @since 8
791     * @syscap SystemCapability.Multimedia.Media.Core
792     */
793    MSERR_OK = 0,
794
795    /**
796     * malloc or new memory failed. maybe system have no memory.
797     * @since 8
798     * @syscap SystemCapability.Multimedia.Media.Core
799     */
800    MSERR_NO_MEMORY = 1,
801
802    /**
803     * no permission for the operation.
804     * @since 8
805     * @syscap SystemCapability.Multimedia.Media.Core
806     */
807    MSERR_OPERATION_NOT_PERMIT = 2,
808
809    /**
810     * invalid argument.
811     * @since 8
812     * @syscap SystemCapability.Multimedia.Media.Core
813     */
814    MSERR_INVALID_VAL = 3,
815
816    /**
817     * an I/O error occurred.
818     * @since 8
819     * @syscap SystemCapability.Multimedia.Media.Core
820     */
821    MSERR_IO = 4,
822
823    /**
824     * operation time out.
825     * @since 8
826     * @syscap SystemCapability.Multimedia.Media.Core
827     */
828    MSERR_TIMEOUT = 5,
829
830    /**
831     * unknown error.
832     * @since 8
833     * @syscap SystemCapability.Multimedia.Media.Core
834     */
835    MSERR_UNKNOWN = 6,
836
837    /**
838     * media service died.
839     * @since 8
840     * @syscap SystemCapability.Multimedia.Media.Core
841     */
842    MSERR_SERVICE_DIED = 7,
843
844    /**
845     * operation is not permit in current state.
846     * @since 8
847     * @syscap SystemCapability.Multimedia.Media.Core
848     */
849    MSERR_INVALID_STATE = 8,
850
851    /**
852     * operation is not supported in current version.
853     * @since 8
854     * @syscap SystemCapability.Multimedia.Media.Core
855     */
856    MSERR_UNSUPPORTED = 9,
857  }
858
859  /**
860   * Enumerates buffering info type, for network playback.
861   * @since 8
862   * @syscap SystemCapability.Multimedia.Media.Core
863   */
864  enum BufferingInfoType {
865    /**
866     * begin to buffering
867     * @since 8
868     * @syscap SystemCapability.Multimedia.Media.Core
869     */
870    BUFFERING_START = 1,
871
872    /**
873     * end to buffering
874     * @since 8
875     * @syscap SystemCapability.Multimedia.Media.Core
876     */
877    BUFFERING_END = 2,
878
879    /**
880     * buffering percent
881     * @since 8
882     * @syscap SystemCapability.Multimedia.Media.Core
883     */
884    BUFFERING_PERCENT = 3,
885
886    /**
887     * cached duration in milliseconds
888     * @since 8
889     * @syscap SystemCapability.Multimedia.Media.Core
890     */
891    CACHED_DURATION = 4,
892  }
893
894  /**
895   * Media file descriptor. The caller needs to ensure that the fd is valid and
896   * the offset and length are correct.
897   * @since 9
898   * @syscap SystemCapability.Multimedia.Media.Core
899   */
900  interface AVFileDescriptor {
901    /**
902     * The file descriptor of audio or video source from file system. The caller
903     * is responsible to close the file descriptor.
904     * @since 9
905     * @syscap SystemCapability.Multimedia.Media.Core
906     */
907    fd: number
908
909    /**
910     * The offset into the file where the data to be read, in bytes. By default,
911     * the offset is zero.
912     * @since 9
913     * @syscap SystemCapability.Multimedia.Media.Core
914     */
915    offset?: number
916
917    /**
918     * The length in bytes of the data to be read. By default, the length is the
919     * rest of bytes in the file from the offset.
920     * @since 9
921     * @syscap SystemCapability.Multimedia.Media.Core
922     */
923    length?: number
924  }
925
926  /**
927    * DataSource descriptor. The caller needs to ensure that the fileSize and
928    * callback is valid.
929    * @since 10
930    * @syscap SystemCapability.Multimedia.Media.Core
931    */
932  interface DataSrcDescriptor {
933    /**
934     * Size of the file, -1 indicates that the file size is unknown. If the fileSize is set to -1,
935     * seek and setSpeed can't be executed, loop can't be set, and can't replay.
936     * @since 10
937     * @syscap SystemCapability.Multimedia.Media.Core
938     */
939    fileSize: number;
940    /**
941     * Callback function implemented by users, which is used to fill data.
942     * @param buffer The buffer need to fill.
943     * @param length The stream length player want to get.
944     * @param pos The stream position player want get start.
945     * @return returns length of the data to be filled.
946     * @since 10
947     * @syscap SystemCapability.Multimedia.Media.Core
948     */
949    callback: (buffer: ArrayBuffer, length: number, pos?: number) => int
950  }
951
952  /**
953   * Describes audio playback states.
954   * @since 6
955   * @syscap SystemCapability.Multimedia.Media.AudioPlayer
956   * @deprecated since 9
957   * @useinstead ohos.multimedia.media/media.AVPlayerState
958   */
959  type AudioState = 'idle' | 'playing' | 'paused' | 'stopped' | 'error';
960
961  /**
962   * Manages and plays audio. Before calling an AudioPlayer method, you must use createAudioPlayer()
963   * to create an AudioPlayer instance.
964   * @since 6
965   * @syscap SystemCapability.Multimedia.Media.AudioPlayer
966   * @deprecated since 9
967   * @useinstead ohos.multimedia.media/media.AVPlayer
968   */
969  interface AudioPlayer {
970    /**
971     * Starts audio playback.
972     * @since 6
973     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
974     * @deprecated since 9
975     * @useinstead ohos.multimedia.media/media.AVPlayer#play
976     */
977    play(): void;
978
979    /**
980     * Pauses audio playback.
981     * @since 6
982     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
983     * @deprecated since 9
984     * @useinstead ohos.multimedia.media/media.AVPlayer#pause
985     */
986    pause(): void;
987
988    /**
989     * Stops audio playback.
990     * @since 6
991     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
992     * @deprecated since 9
993     * @useinstead ohos.multimedia.media/media.AVPlayer#stop
994     */
995    stop(): void;
996
997    /**
998     * Resets audio playback.
999     * @since 7
1000     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1001     * @deprecated since 9
1002     * @useinstead ohos.multimedia.media/media.AVPlayer#reset
1003     */
1004    reset(): void;
1005
1006    /**
1007     * Jumps to the specified playback position.
1008     * @since 6
1009     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1010     * @param timeMs Playback position to jump
1011     * @deprecated since 9
1012     * @useinstead ohos.multimedia.media/media.AVPlayer#seek
1013     */
1014    seek(timeMs: number): void;
1015
1016    /**
1017     * Sets the volume.
1018     * @since 6
1019     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1020     * @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%).
1021     * @deprecated since 9
1022     * @useinstead ohos.multimedia.media/media.AVPlayer#setVolume
1023     */
1024    setVolume(vol: number): void;
1025
1026    /**
1027     * Releases resources used for audio playback.
1028     * @since 6
1029     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1030     * @deprecated since 9
1031     * @useinstead ohos.multimedia.media/media.AVPlayer#release
1032     */
1033    release(): void;
1034
1035    /**
1036     * Get all track infos in MediaDescription, should be called after data loaded callback.
1037     * @since 8
1038     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1039     * @param callback async callback return track info in MediaDescription.
1040     * @deprecated since 9
1041     * @useinstead ohos.multimedia.media/media.AVPlayer#getTrackDescription
1042     */
1043    getTrackDescription(callback: AsyncCallback<Array<MediaDescription>>): void;
1044
1045    /**
1046     * Get all track infos in MediaDescription, should be called after data loaded callback.
1047     * @since 8
1048     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1049     * @returns A Promise instance used to return the track info in MediaDescription.
1050     * @deprecated since 9
1051     * @useinstead ohos.multimedia.media/media.AVPlayer#getTrackDescription
1052     */
1053    getTrackDescription() : Promise<Array<MediaDescription>>;
1054
1055    /**
1056     * Listens for audio playback buffering events.
1057     * @since 8
1058     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1059     * @param type Type of the playback buffering update event to listen for.
1060     * @param callback Callback used to listen for the buffering update event, return BufferingInfoType and the value.
1061     * @deprecated since 9
1062     * @useinstead ohos.multimedia.media/media.AVPlayer#event:bufferingUpdate
1063     */
1064    on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void;
1065
1066    /**
1067     * Audio media URI. Mainstream audio formats are supported.
1068     * local:fd://XXX, file://XXX. network:http://xxx
1069     * @since 6
1070     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1071     * @permission ohos.permission.READ_MEDIA or ohos.permission.INTERNET
1072     * @deprecated since 9
1073     * @useinstead ohos.multimedia.media/media.AVPlayer#url
1074     */
1075    src: string;
1076
1077    /**
1078     * Audio file descriptor. Mainstream audio formats are supported.
1079     * @since 9
1080     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1081     * @deprecated since 9
1082     * @useinstead ohos.multimedia.media/media.AVPlayer#fdSrc
1083     */
1084    fdSrc: AVFileDescriptor;
1085
1086    /**
1087     * Whether to loop audio playback. The value true means to loop playback.
1088     * @since 6
1089     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1090     * @deprecated since 9
1091     * @useinstead ohos.multimedia.media/media.AVPlayer#loop
1092     */
1093    loop: boolean;
1094
1095    /**
1096     * Describes audio interrupt mode, refer to {@link #audio.InterruptMode}. If it is not
1097     * set, the default mode will be used. Set it before calling the {@link #play()} in the
1098     * first time in order for the interrupt mode to become effective thereafter.
1099     * @since 9
1100     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1101     * @deprecated since 9
1102     * @useinstead ohos.multimedia.media/media.AVPlayer#audioInterruptMode
1103     */
1104    audioInterruptMode ?: audio.InterruptMode;
1105
1106    /**
1107     * Current playback position.
1108     * @since 6
1109     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1110     * @deprecated since 9
1111     * @useinstead ohos.multimedia.media/media.AVPlayer#currentTime
1112     */
1113    readonly currentTime: number;
1114
1115    /**
1116     * Playback duration, When the data source does not support seek, it returns - 1, such as a live broadcast scenario.
1117     * @since 6
1118     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1119     * @deprecated since 9
1120     * @useinstead ohos.multimedia.media/media.AVPlayer#duration
1121     */
1122    readonly duration: number;
1123
1124    /**
1125     * Playback state.
1126     * @since 6
1127     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1128     * @deprecated since 9
1129     * @useinstead ohos.multimedia.media/media.AVPlayer#state
1130     */
1131    readonly state: AudioState;
1132
1133    /**
1134     * Listens for audio playback events.
1135     * @since 6
1136     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1137     * @param type Type of the playback event to listen for.
1138     * @param callback Callback used to listen for the playback event.
1139     * @deprecated since 9
1140     * @useinstead ohos.multimedia.media/media.AVPlayer#event:stateChange
1141     */
1142    on(type: 'play' | 'pause' | 'stop' | 'reset' | 'dataLoad' | 'finish' | 'volumeChange', callback: () => void): void;
1143
1144    /**
1145     * Listens for audio playback events.
1146     * @since 6
1147     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1148     * @param type Type of the playback event to listen for.
1149     * @param callback Callback used to listen for the playback event.
1150     * @deprecated since 9
1151     * @useinstead ohos.multimedia.media/media.AVPlayer#event:timeUpdate
1152     */
1153    on(type: 'timeUpdate', callback: Callback<number>): void;
1154
1155    /**
1156     * Listens for audio interrupt event, refer to {@link #audio.InterruptEvent}
1157     * @since 9
1158     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1159     * @param type Type of the playback event to listen for.
1160     * @param callback Callback used to listen for the playback event return audio interrupt info.
1161     * @deprecated since 9
1162     * @useinstead ohos.multimedia.media/media.AVPlayer#event:audioInterrupt
1163     */
1164    on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void;
1165
1166    /**
1167     * Listens for playback error events.
1168     * @since 6
1169     * @syscap SystemCapability.Multimedia.Media.AudioPlayer
1170     * @param type Type of the playback error event to listen for.
1171     * @param callback Callback used to listen for the playback error event.
1172     * @deprecated since 9
1173     * @useinstead ohos.multimedia.media/media.AVPlayer#event:error
1174     */
1175    on(type: 'error', callback: ErrorCallback): void;
1176  }
1177
1178  /**
1179  * Describes media recorder states.
1180  * @since 9
1181  * @syscap SystemCapability.Multimedia.Media.AVRecorder
1182  */
1183  type AVRecorderState = 'idle' | 'prepared' | 'started' | 'paused' | 'stopped' | 'released' | 'error';
1184
1185  /**
1186   * Manages and record audio/video. Before calling an AVRecorder method, you must use createAVRecorder()
1187   * to create an AVRecorder instance.
1188   * @since 9
1189   * @syscap SystemCapability.Multimedia.Media.AVRecorder
1190   */
1191  interface AVRecorder {
1192    /**
1193     * Prepares for recording.
1194     * @since 9
1195     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1196     * @param config Recording parameters.
1197     * @param callback A callback instance used to return when prepare completed.
1198     * @permission ohos.permission.MICROPHONE
1199     * @throws { BusinessError } 201 - Permission denied. Return by callback.
1200     * @throws { BusinessError } 401 - Parameter error. Return by callback.
1201     * @throws { BusinessError } 5400102 - Operate not permit. Return by callback.
1202     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1203     */
1204    prepare(config: AVRecorderConfig, callback: AsyncCallback<void>): void;
1205
1206    /**
1207     * Prepares for recording.
1208     * @since 9
1209     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1210     * @param config Recording parameters.
1211     * @returns A Promise instance used to return when prepare completed.
1212     * @permission ohos.permission.MICROPHONE
1213     * @throws { BusinessError } 201 - Permission denied. Return by promise.
1214     * @throws { BusinessError } 401 - Parameter error. Return by promise.
1215     * @throws { BusinessError } 5400102 - Operate not permit. Return by promise.
1216     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1217     */
1218    prepare(config: AVRecorderConfig): Promise<void>;
1219
1220    /**
1221     * Get input surface.it must be called between prepare completed and start.
1222     * @since 9
1223     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1224     * @param callback Callback used to return the input surface id in string.
1225     * @throws { BusinessError } 5400102 - Operate not permit. Return by callback.
1226     * @throws { BusinessError } 5400103 - IO error. Return by callback.
1227     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1228     */
1229    getInputSurface(callback: AsyncCallback<string>): void;
1230
1231    /**
1232     * Get input surface. it must be called between prepare completed and start.
1233     * @since 9
1234     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1235     * @returns A Promise instance used to return the input surface id in string.
1236     * @throws { BusinessError } 5400102 - Operate not permit. Return by promise.
1237     * @throws { BusinessError } 5400103 - IO error. Return by promise.
1238     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1239     */
1240    getInputSurface(): Promise<string>;
1241
1242    /**
1243     * Start AVRecorder, it will to started state.
1244     * @since 9
1245     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1246     * @param callback A callback instance used to return when start completed.
1247     * @throws { BusinessError } 5400102 - Operate not permit. Return by callback.
1248     * @throws { BusinessError } 5400103 - IO error. Return by callback.
1249     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1250     */
1251    start(callback: AsyncCallback<void>): void;
1252
1253    /**
1254     * Start AVRecorder, it will to started state.
1255     * @since 9
1256     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1257     * @returns A Promise instance used to return when start completed.
1258     * @throws { BusinessError } 5400102 - Operate not permit. Return by promise.
1259     * @throws { BusinessError } 5400103 - IO error. Return by promise.
1260     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1261     */
1262    start(): Promise<void>;
1263
1264    /**
1265     * Start AVRecorder, it will to paused state.
1266     * @since 9
1267     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1268     * @param callback A callback instance used to return when pause completed.
1269     * @throws { BusinessError } 5400102 - Operate not permit. Return by callback.
1270     * @throws { BusinessError } 5400103 - IO error. Return by callback.
1271     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1272     */
1273    pause(callback: AsyncCallback<void>): void;
1274
1275    /**
1276     * Start AVRecorder, it will to paused state.
1277     * @since 9
1278     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1279     * @returns A Promise instance used to return when pause completed.
1280     * @throws { BusinessError } 5400102 - Operate not permit. Return by promise.
1281     * @throws { BusinessError } 5400103 - IO error. Return by promise.
1282     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1283     */
1284    pause(): Promise<void>;
1285
1286    /**
1287     * Resume AVRecorder, it will to started state.
1288     * @since 9
1289     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1290     * @param callback A callback instance used to return when resume completed.
1291     * @throws { BusinessError } 5400102 - Operate not permit. Return by callback.
1292     * @throws { BusinessError } 5400103 - IO error. Return by callback.
1293     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1294     */
1295    resume(callback: AsyncCallback<void>): void;
1296
1297    /**
1298     * Resume AVRecorder, it will to started state.
1299     * @since 9
1300     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1301     * @returns A Promise instance used to return when resume completed.
1302     * @throws { BusinessError } 5400102 - Operate not permit. Return by promise.
1303     * @throws { BusinessError } 5400103 - IO error. Return by promise.
1304     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1305     */
1306    resume(): Promise<void>;
1307
1308    /**
1309     * Stop AVRecorder, it will to stopped state.
1310     * @since 9
1311     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1312     * @param callback A callback instance used to return when stop completed.
1313     * @throws { BusinessError } 5400102 - Operate not permit. Return by callback.
1314     * @throws { BusinessError } 5400103 - IO error. Return by callback.
1315     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1316     */
1317    stop(callback: AsyncCallback<void>): void;
1318
1319    /**
1320     * Stop AVRecorder, it will to stopped state.
1321     * @since 9
1322     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1323     * @returns A Promise instance used to return when stop completed.
1324     * @throws { BusinessError } 5400102 - Operate not permit. Return by promise.
1325     * @throws { BusinessError } 5400103 - IO error. Return by promise.
1326     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1327     */
1328    stop(): Promise<void>;
1329
1330    /**
1331     * Reset AVRecorder, it will to idle state.
1332     * @since 9
1333     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1334     * @param callback A callback instance used to return when reset completed.
1335     * @throws { BusinessError } 5400103 - IO error. Return by callback.
1336     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1337     */
1338    reset(callback: AsyncCallback<void>): void;
1339
1340    /**
1341     * Reset AVRecorder, it will to idle state.
1342     * @since 9
1343     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1344     * @returns A Promise instance used to return when reset completed.
1345     * @throws { BusinessError } 5400103 - IO error. Return by promise.
1346     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1347     */
1348    reset(): Promise<void>;
1349
1350    /**
1351     * Releases resources used for AVRecorder, it will to released state.
1352     * @since 9
1353     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1354     * @param callback A callback instance used to return when release completed.
1355     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1356     */
1357    release(callback: AsyncCallback<void>): void;
1358
1359    /**
1360     * Releases resources used for AVRecorder, it will to released state.
1361     * @since 9
1362     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1363     * @returns A Promise instance used to return when release completed.
1364     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1365     */
1366    release(): Promise<void>;
1367
1368    /**
1369     * getAVRecorderProfile for recording.
1370     * @since 10
1371     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1372     * @param config Recording parameters.
1373     * @param callback A callback instance used to return when prepare completed.
1374     * @throws { BusinessError } 401 - Parameter error. Return by callback.
1375     * @throws { BusinessError } 5400102 - Operate not permit. Return by callback.
1376     */
1377    getAVRecorderProfile(sourceId: number, qualityLevel: VideoRecorderQualityLevel): Promise<AVRecorderProfile>;
1378
1379    /**
1380     * getAVRecorderProfile for recording.
1381     * @since 10
1382     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1383     * @param config Recording parameters.
1384     * @param callback A callback instance used to return when prepare completed.
1385     * @throws { BusinessError } 401 - Parameter error. Return by callback.
1386     * @throws { BusinessError } 5400102 - Operate not permit. Return by callback.
1387     */
1388    getAVRecorderProfile(sourceId: number, qualityLevel: VideoRecorderQualityLevel, callback: AsyncCallback<AVRecorderProfile>);
1389
1390    /**
1391     * setAVRecorderConfig for recording.
1392     * @since 10
1393     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1394     * @param config Recording parameters.
1395     * @param callback A callback instance used to return when prepare completed.
1396     * @permission ohos.permission.MICROPHONE
1397     * @throws { BusinessError } 401 - Parameter error. Return by callback.
1398     * @throws { BusinessError } 5400102 - Operate not permit. Return by callback.
1399     */
1400    setAVRecorderConfig(config: AVRecorderConfig, callback: AsyncCallback<void>): void;
1401
1402    /**
1403     * setAVRecorderConfig for recording.
1404     * @since 10
1405     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1406     * @param config Recording parameters.
1407     * @returns A Promise instance used to return when prepare completed.
1408     * @permission ohos.permission.MICROPHONE
1409     * @throws { BusinessError } 401 - Parameter error. Return by promise.
1410     * @throws { BusinessError } 5400102 - Operate not permit. Return by promise.
1411     */
1412    setAVRecorderConfig(config: AVRecorderConfig): Promise<void>;
1413
1414    /**
1415     * Recorder state.
1416     * @since 9
1417     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1418     */
1419    readonly state: AVRecorderState;
1420
1421    /**
1422     * Listens for recording stateChange events.
1423     * @since 9
1424     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1425     * @param type Type of the recording event to listen for.
1426     * @param callback Callback used to listen for the recorder stateChange event.
1427     * @throws { BusinessError } 5400103 - IO error. Return by callback.
1428     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1429     */
1430    on(type: 'stateChange', callback: (state: AVRecorderState, reason: StateChangeReason) => void): void;
1431
1432    /**
1433     * Listens for recording error events.
1434     * @since 9
1435     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1436     * @param type Type of the recording error event to listen for.
1437     * @param callback Callback used to listen for the recorder error event.
1438     * @throws { BusinessError } 201 - Permission denied.
1439     * @throws { BusinessError } 401 - The parameter check failed.
1440     * @throws { BusinessError } 801 - Capability not supported.
1441     * @throws { BusinessError } 5400101 - No memory.
1442     * @throws { BusinessError } 5400102 - Operation not allowed.
1443     * @throws { BusinessError } 5400103 - I/O error.
1444     * @throws { BusinessError } 5400104 - Time out.
1445     * @throws { BusinessError } 5400105 - Service died.
1446     * @throws { BusinessError } 5400106 - Unsupport format.
1447     */
1448    on(type: 'error', callback: ErrorCallback): void;
1449
1450    /**
1451     * Cancel Listens for recording stateChange events.
1452     * @since 9
1453     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1454     * @param type Type of the recording stateChange event to listen for.
1455     */
1456    off(type: 'stateChange'): void;
1457
1458    /**
1459     * Cancel Listens for recording error events.
1460     * @since 9
1461     * @syscap SystemCapability.Multimedia.Media.AVRecorder
1462     * @param type Type of the recording error event to listen for.
1463     */
1464    off(type: 'error'): void;
1465  }
1466
1467  /**
1468   * Enumerates audio encoding formats, it will be deprecated after API8, use @CodecMimeType to replace.
1469   * @since 6
1470   * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1471   * @deprecated since 8
1472   * @useinstead ohos.multimedia.media/media.CodecMimeType
1473   */
1474  enum AudioEncoder {
1475    /**
1476     * Default audio encoding format, which is AMR-NB.
1477     * @since 6
1478     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1479     */
1480    DEFAULT = 0,
1481
1482    /**
1483     * Indicates the AMR-NB audio encoding format.
1484     * @since 6
1485     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1486     */
1487    AMR_NB = 1,
1488
1489    /**
1490     * Indicates the AMR-WB audio encoding format.
1491     * @since 6
1492     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1493     */
1494    AMR_WB = 2,
1495
1496    /**
1497     * Advanced Audio Coding Low Complexity (AAC-LC).
1498     * @since 6
1499     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1500     */
1501    AAC_LC = 3,
1502
1503    /**
1504     * High-Efficiency Advanced Audio Coding (HE-AAC).
1505     * @since 6
1506     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1507     */
1508    HE_AAC = 4
1509  }
1510
1511  /**
1512   * Enumerates audio output formats, it will be deprecated after API8, use @ContainerFormatType to replace.
1513   * @since 6
1514   * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1515   * @deprecated since 8
1516   * @useinstead ohos.multimedia.media/media.ContainerFormatType
1517   */
1518  enum AudioOutputFormat {
1519    /**
1520     * Default audio output format, which is Moving Pictures Expert Group 4 (MPEG-4).
1521     * @since 6
1522     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1523     */
1524    DEFAULT = 0,
1525
1526    /**
1527     * Indicates the Moving Picture Experts Group-4 (MPEG4) media format.
1528     * @since 6
1529     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1530     */
1531    MPEG_4 = 2,
1532
1533    /**
1534     * Indicates the Adaptive Multi-Rate Narrowband (AMR-NB) media format.
1535     * @since 6
1536     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1537     */
1538    AMR_NB = 3,
1539
1540    /**
1541     * Indicates the Adaptive Multi-Rate Wideband (AMR-WB) media format.
1542     * @since 6
1543     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1544     */
1545    AMR_WB = 4,
1546
1547    /**
1548     * Audio Data Transport Stream (ADTS), a transmission stream format of Advanced Audio Coding (AAC) audio.
1549     * @since 6
1550     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1551     */
1552    AAC_ADTS = 6
1553  }
1554
1555  /**
1556   * Provides the geographical location definitions for media resources.
1557   * @since 6
1558   * @syscap SystemCapability.Multimedia.Media.Core
1559   */
1560  interface Location {
1561    /**
1562     * Latitude.
1563     * @since 6
1564     * @syscap SystemCapability.Multimedia.Media.Core
1565     */
1566    latitude: number;
1567
1568    /**
1569     * Longitude.
1570     * @since 6
1571     * @syscap SystemCapability.Multimedia.Media.Core
1572     */
1573    longitude: number;
1574  }
1575
1576  /**
1577   * Provides the audio recorder configuration definitions.
1578   * @since 6
1579   * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1580   * @deprecated since 9
1581   * @useinstead ohos.multimedia.media/media.AVRecorderConfig
1582   */
1583  interface AudioRecorderConfig {
1584    /**
1585     * Audio encoding format. The default value is DEFAULT, it will be deprecated after API8.
1586     * use "audioEncoderMime" instead.
1587     * @since 6
1588     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1589     * @deprecated since 8
1590     * @useinstead ohos.multimedia.media/media.AudioRecorderConfig.audioEncoderMime
1591     */
1592    audioEncoder?: AudioEncoder;
1593
1594    /**
1595     * Audio encoding bit rate.
1596     * @since 6
1597     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1598     * @deprecated since 9
1599     */
1600    audioEncodeBitRate?: number;
1601
1602    /**
1603     * Audio sampling rate.
1604     * @since 6
1605     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1606     * @deprecated since 9
1607     */
1608    audioSampleRate?: number;
1609
1610    /**
1611     * Number of audio channels.
1612     * @since 6
1613     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1614     * @deprecated since 9
1615     */
1616    numberOfChannels?: number;
1617
1618    /**
1619     * Audio output format. The default value is DEFAULT, it will be deprecated after API8.
1620     * it will be replaced with "fileFormat".
1621     * @since 6
1622     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1623     * @deprecated since 8
1624     * @useinstead ohos.multimedia.media/media.AudioRecorderConfig.fileFormat
1625     */
1626    format?: AudioOutputFormat;
1627
1628    /**
1629     * Audio output uri.support two kind of uri now.
1630     * format like: scheme + "://" + "context".
1631     * file:  file://path
1632     * fd:    fd://fd
1633     * @since 6
1634     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1635     * @deprecated since 9
1636     */
1637    uri: string;
1638
1639    /**
1640     * Geographical location information.
1641     * @since 6
1642     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1643     * @deprecated since 9
1644     */
1645    location?: Location;
1646
1647    /**
1648     * audio encoding format MIME. it used to replace audioEncoder.
1649     * @since 8
1650     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1651     * @deprecated since 9
1652     */
1653    audioEncoderMime?: CodecMimeType;
1654    /**
1655     * output file format. see @ContainerFormatType , it used to replace "format".
1656     * @since 8
1657     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1658     * @deprecated since 9
1659     */
1660    fileFormat?: ContainerFormatType;
1661  }
1662
1663  /**
1664   * Manages and record audio. Before calling an AudioRecorder method, you must use createAudioRecorder()
1665   * to create an AudioRecorder instance.
1666   * @since 6
1667   * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1668   * @deprecated since 9
1669   * @useinstead ohos.multimedia.media/media.AVRecorder
1670   */
1671  interface AudioRecorder {
1672    /**
1673     * Prepares for recording.
1674     * @since 6
1675     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1676     * @param config Recording parameters.
1677     * @permission ohos.permission.MICROPHONE
1678     * @deprecated since 9
1679     * @useinstead ohos.multimedia.media/media.AVRecorder#prepare
1680     */
1681    prepare(config: AudioRecorderConfig): void;
1682
1683    /**
1684     * Starts audio recording.
1685     * @since 6
1686     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1687     * @deprecated since 9
1688     * @useinstead ohos.multimedia.media/media.AVRecorder#start
1689     */
1690    start(): void;
1691
1692    /**
1693     * Pauses audio recording.
1694     * @since 6
1695     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1696     * @deprecated since 9
1697     * @useinstead ohos.multimedia.media/media.AVRecorder#pause
1698     */
1699    pause(): void;
1700
1701    /**
1702     * Resumes audio recording.
1703     * @since 6
1704     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1705     * @deprecated since 9
1706     * @useinstead ohos.multimedia.media/media.AVRecorder#resume
1707     */
1708    resume(): void;
1709
1710    /**
1711     * Stops audio recording.
1712     * @since 6
1713     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1714     * @deprecated since 9
1715     * @useinstead ohos.multimedia.media/media.AVRecorder#stop
1716     */
1717    stop(): void;
1718
1719    /**
1720     * Releases resources used for audio recording.
1721     * @since 6
1722     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1723     * @deprecated since 9
1724     * @useinstead ohos.multimedia.media/media.AVRecorder#release
1725     */
1726    release(): void;
1727
1728    /**
1729     * Resets audio recording.
1730     * Before resetting audio recording, you must call stop() to stop recording. After audio recording is reset,
1731     * you must call prepare() to set the recording configurations for another recording.
1732     * @since 6
1733     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1734     * @deprecated since 9
1735     * @useinstead ohos.multimedia.media/media.AVRecorder#reset
1736     */
1737    reset(): void;
1738
1739    /**
1740     * Listens for audio recording events.
1741     * @since 6
1742     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1743     * @param type Type of the audio recording event to listen for.
1744     * @param callback Callback used to listen for the audio recording event.
1745     * @deprecated since 9
1746     * @useinstead ohos.multimedia.media/media.AVRecorder#on
1747     */
1748    on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset', callback: () => void): void;
1749
1750    /**
1751     * Listens for audio recording error events.
1752     * @since 6
1753     * @syscap SystemCapability.Multimedia.Media.AudioRecorder
1754     * @param type Type of the audio recording error event to listen for.
1755     * @param callback Callback used to listen for the audio recording error event.
1756     * @deprecated since 9
1757     * @useinstead ohos.multimedia.media/media.AVRecorder#on
1758     */
1759    on(type: 'error', callback: ErrorCallback): void;
1760  }
1761
1762  /**
1763  * The maintenance of this interface has been stopped since version api 9. Please use AVRecorderState.
1764  * Describes video recorder states.
1765  * @since 9
1766  * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1767  * @systemapi
1768  */
1769  type VideoRecordState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error';
1770
1771  /**
1772   * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder.
1773   * Manages and record video. Before calling an VideoRecorder method, you must use createVideoRecorder()
1774   * to create an VideoRecorder instance.
1775   * @since 9
1776   * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1777   * @systemapi
1778   */
1779  interface VideoRecorder {
1780    /**
1781     * Prepares for recording.
1782     * @since 9
1783     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1784     * @param config Recording parameters.
1785     * @param callback A callback instance used to return when prepare completed.
1786     * @permission ohos.permission.MICROPHONE
1787     * @throws { BusinessError } 201 - Permission denied. Return by callback.
1788     * @throws { BusinessError } 401 - Parameter error. Return by callback.
1789     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
1790     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1791     * @systemapi
1792     */
1793    prepare(config: VideoRecorderConfig, callback: AsyncCallback<void>): void;
1794    /**
1795     * Prepares for recording.
1796     * @since 9
1797     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1798     * @param config Recording parameters.
1799     * @returns A Promise instance used to return when prepare completed.
1800     * @permission ohos.permission.MICROPHONE
1801     * @throws { BusinessError } 201 - Permission denied. Return by promise.
1802     * @throws { BusinessError } 401 - Parameter error. Return by promise.
1803     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
1804     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1805     * @systemapi
1806     */
1807    prepare(config: VideoRecorderConfig): Promise<void>;
1808    /**
1809     * get input surface.it must be called between prepare completed and start.
1810     * @since 9
1811     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1812     * @param callback Callback used to return the input surface id in string.
1813     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
1814     * @throws { BusinessError } 5400103 - I/O error. Return by callback.
1815     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1816     * @systemapi
1817     */
1818    getInputSurface(callback: AsyncCallback<string>): void;
1819    /**
1820     * get input surface. it must be called between prepare completed and start.
1821     * @since 9
1822     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1823     * @returns A Promise instance used to return the input surface id in string.
1824     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
1825     * @throws { BusinessError } 5400103 - I/O error. Return by promise.
1826     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1827     * @systemapi
1828     */
1829    getInputSurface(): Promise<string>;
1830    /**
1831     * Starts video recording.
1832     * @since 9
1833     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1834     * @param callback A callback instance used to return when start completed.
1835     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
1836     * @throws { BusinessError } 5400103 - I/O error. Return by callback.
1837     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1838     * @systemapi
1839     */
1840    start(callback: AsyncCallback<void>): void;
1841    /**
1842     * Starts video recording.
1843     * @since 9
1844     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1845     * @returns A Promise instance used to return when start completed.
1846     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
1847     * @throws { BusinessError } 5400103 - I/O error. Return by promise.
1848     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1849     * @systemapi
1850     */
1851    start(): Promise<void>;
1852    /**
1853     * Pauses video recording.
1854     * @since 9
1855     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1856     * @param callback A callback instance used to return when pause completed.
1857     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
1858     * @throws { BusinessError } 5400103 - I/O error. Return by callback.
1859     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1860     * @systemapi
1861     */
1862    pause(callback: AsyncCallback<void>): void;
1863    /**
1864     * Pauses video recording.
1865     * @since 9
1866     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1867     * @returns A Promise instance used to return when pause completed.
1868     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
1869     * @throws { BusinessError } 5400103 - I/O error. Return by promise.
1870     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1871     * @systemapi
1872     */
1873    pause(): Promise<void>;
1874    /**
1875     * Resumes video recording.
1876     * @since 9
1877     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1878     * @param callback A callback instance used to return when resume completed.
1879     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
1880     * @throws { BusinessError } 5400103 - I/O error. Return by callback.
1881     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1882     * @systemapi
1883     */
1884    resume(callback: AsyncCallback<void>): void;
1885    /**
1886     * Resumes video recording.
1887     * @since 9
1888     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1889     * @returns A Promise instance used to return when resume completed.
1890     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
1891     * @throws { BusinessError } 5400103 - I/O error. Return by promise.
1892     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1893     * @systemapi
1894     */
1895    resume(): Promise<void>;
1896    /**
1897     * Stops video recording.
1898     * @since 9
1899     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1900     * @param callback A callback instance used to return when stop completed.
1901     * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
1902     * @throws { BusinessError } 5400103 - I/O error. Return by callback.
1903     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1904     * @systemapi
1905     */
1906    stop(callback: AsyncCallback<void>): void;
1907    /**
1908     * Stops video recording.
1909     * @since 9
1910     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1911     * @returns A Promise instance used to return when stop completed.
1912     * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
1913     * @throws { BusinessError } 5400103 - I/O error. Return by promise.
1914     * @throws { BusinessError } 5400105 - Service died. Return by promise.
1915     * @systemapi
1916     */
1917    stop(): Promise<void>;
1918    /**
1919     * Releases resources used for video recording.
1920     * @since 9
1921     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1922     * @param callback A callback instance used to return when release completed.
1923     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1924     * @systemapi
1925     */
1926    release(callback: AsyncCallback<void>): void;
1927    /**
1928      * Releases resources used for video recording.
1929      * @since 9
1930      * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1931      * @returns A Promise instance used to return when release completed.
1932      * @throws { BusinessError } 5400105 - Service died. Return by callback.
1933      * @systemapi
1934      */
1935    release(): Promise<void>;
1936    /**
1937     * Resets video recording.
1938     * Before resetting video recording, you must call stop() to stop recording. After video recording is reset,
1939     * you must call prepare() to set the recording configurations for another recording.
1940     * @since 9
1941     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1942     * @param callback A callback instance used to return when reset completed.
1943     * @throws { BusinessError } 5400103 - I/O error. Return by callback.
1944     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1945     * @systemapi
1946     */
1947    reset(callback: AsyncCallback<void>): void;
1948     /**
1949      * Resets video recording.
1950      * Before resetting video recording, you must call stop() to stop recording. After video recording is reset,
1951      * you must call prepare() to set the recording configurations for another recording.
1952      * @since 9
1953      * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1954      * @returns A Promise instance used to return when reset completed.
1955      * @throws { BusinessError } 5400103 - I/O error. Return by promise.
1956      * @throws { BusinessError } 5400105 - Service died. Return by promise.
1957      * @systemapi
1958      */
1959    reset(): Promise<void>;
1960    /**
1961     * Listens for video recording error events.
1962     * @since 9
1963     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1964     * @param type Type of the video recording error event to listen for.
1965     * @param callback Callback used to listen for the video recording error event.
1966     * @throws { BusinessError } 5400103 - I/O error. Return by callback.
1967     * @throws { BusinessError } 5400105 - Service died. Return by callback.
1968     * @systemapi
1969     */
1970    on(type: 'error', callback: ErrorCallback): void;
1971
1972    /**
1973     * video recorder state.
1974     * @since 9
1975     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
1976     * @systemapi
1977     */
1978     readonly state: VideoRecordState;
1979  }
1980
1981  /**
1982   * Describes video playback states.
1983   * @since 8
1984   * @syscap SystemCapability.Multimedia.Media.VideoPlayer
1985   * @deprecated since 9
1986   * @useinstead ohos.multimedia.media/media.AVPlayerState
1987   */
1988  type VideoPlayState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error';
1989
1990  /**
1991   * Enumerates playback speed.
1992   * @since 8
1993   * @syscap SystemCapability.Multimedia.Media.VideoPlayer
1994   */
1995  enum PlaybackSpeed {
1996    /**
1997     * playback at 0.75x normal speed
1998     * @since 8
1999     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2000     */
2001    SPEED_FORWARD_0_75_X = 0,
2002    /**
2003     * playback at normal speed
2004     * @since 8
2005     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2006     */
2007    SPEED_FORWARD_1_00_X = 1,
2008    /**
2009     * playback at 1.25x normal speed
2010     * @since 8
2011     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2012     */
2013    SPEED_FORWARD_1_25_X = 2,
2014    /**
2015     * playback at 1.75x normal speed
2016     * @since 8
2017     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2018     */
2019    SPEED_FORWARD_1_75_X = 3,
2020    /**
2021     * playback at 2.0x normal speed
2022     * @since 8
2023     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2024     */
2025    SPEED_FORWARD_2_00_X = 4,
2026  }
2027
2028  /**
2029   * Manages and plays video. Before calling an video method, you must use createVideoPlayer() to create an VideoPlayer
2030   * instance.
2031   * @since 8
2032   * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2033   * @deprecated since 9
2034   * @useinstead ohos.multimedia.media/media.AVPlayer
2035   */
2036  interface VideoPlayer {
2037    /**
2038     * Set display surface.
2039     * @since 8
2040     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2041     * @param surfaceId surface id, video player will use this id get a surface instance.
2042     * @returns A Promise instance used to return when release output buffer completed.
2043     * @deprecated since 9
2044     * @useinstead ohos.multimedia.media/media.AVPlayer#surfaceId
2045     */
2046    setDisplaySurface(surfaceId: string, callback: AsyncCallback<void>): void;
2047    /**
2048     * Set display surface.
2049     * @since 8
2050     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2051     * @param surfaceId surface id, video player will use this id get a surface instance.
2052     * @returns A Promise instance used to return when release output buffer completed.
2053     * @deprecated since 9
2054     * @useinstead ohos.multimedia.media/media.AVPlayer#surfaceId
2055     */
2056    setDisplaySurface(surfaceId: string): Promise<void>;
2057    /**
2058     * Prepare video playback, it will request resource for playing.
2059     * @since 8
2060     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2061     * @param callback A callback instance used to return when prepare completed.
2062     * @deprecated since 9
2063     * @useinstead ohos.multimedia.media/media.AVPlayer#prepare
2064     */
2065    prepare(callback: AsyncCallback<void>): void;
2066    /**
2067     * Prepare video playback, it will request resource for playing.
2068     * @since 8
2069     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2070     * @returns A Promise instance used to return when prepare completed.
2071     * @deprecated since 9
2072     * @useinstead ohos.multimedia.media/media.AVPlayer#prepare
2073     */
2074    prepare(): Promise<void>;
2075    /**
2076     * Starts video playback.
2077     * @since 8
2078     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2079     * @param callback A callback instance used to return when start completed.
2080     * @deprecated since 9
2081     * @useinstead ohos.multimedia.media/media.AVPlayer#play
2082     */
2083    play(callback: AsyncCallback<void>): void;
2084    /**
2085     * Starts video playback.
2086     * @since 8
2087     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2088     * @returns A Promise instance used to return when start completed.
2089     * @deprecated since 9
2090     * @useinstead ohos.multimedia.media/media.AVPlayer#play
2091     */
2092    play(): Promise<void>;
2093    /**
2094     * Pauses video playback.
2095     * @since 8
2096     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2097     * @param callback A callback instance used to return when pause completed.
2098     * @deprecated since 9
2099     * @useinstead ohos.multimedia.media/media.AVPlayer#pause
2100     */
2101    pause(callback: AsyncCallback<void>): void;
2102    /**
2103     * Pauses video playback.
2104     * @since 8
2105     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2106     * @returns A Promise instance used to return when pause completed.
2107     * @deprecated since 9
2108     * @useinstead ohos.multimedia.media/media.AVPlayer#pause
2109     */
2110    pause(): Promise<void>;
2111    /**
2112     * Stops video playback.
2113     * @since 8
2114     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2115     * @param callback A callback instance used to return when stop completed.
2116     * @deprecated since 9
2117     * @useinstead ohos.multimedia.media/media.AVPlayer#stop
2118     */
2119    stop(callback: AsyncCallback<void>): void;
2120    /**
2121     * Stops video playback.
2122     * @since 8
2123     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2124     * @returns A Promise instance used to return when stop completed.
2125     * @deprecated since 9
2126     * @useinstead ohos.multimedia.media/media.AVPlayer#stop
2127     */
2128    stop(): Promise<void>;
2129    /**
2130     * Resets video playback, it will release the resource.
2131     * @since 8
2132     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2133     * @param callback A callback instance used to return when reset completed.
2134     * @deprecated since 9
2135     * @useinstead ohos.multimedia.media/media.AVPlayer#reset
2136     */
2137    reset(callback: AsyncCallback<void>): void;
2138    /**
2139     * Resets video playback, it will release the resource.
2140     * @since 8
2141     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2142     * @returns A Promise instance used to return when reset completed.
2143     * @deprecated since 9
2144     * @useinstead ohos.multimedia.media/media.AVPlayer#reset
2145     */
2146    reset(): Promise<void>;
2147    /**
2148     * Jumps to the specified playback position by default SeekMode(SEEK_PREV_SYNC),
2149     * the performance may be not the best.
2150     * @since 8
2151     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2152     * @param timeMs Playback position to jump
2153     * @param callback A callback instance used to return when seek completed
2154     * and return the seeking position result.
2155     * @deprecated since 9
2156     * @useinstead ohos.multimedia.media/media.AVPlayer#seek
2157     */
2158    seek(timeMs: number, callback: AsyncCallback<number>): void;
2159    /**
2160     * Jumps to the specified playback position.
2161     * @since 8
2162     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2163     * @param timeMs Playback position to jump
2164     * @param mode seek mode, see @SeekMode .
2165     * @param callback A callback instance used to return when seek completed
2166     * and return the seeking position result.
2167     * @deprecated since 9
2168     * @useinstead ohos.multimedia.media/media.AVPlayer#seek
2169     */
2170    seek(timeMs: number, mode:SeekMode, callback: AsyncCallback<number>): void;
2171    /**
2172     * Jumps to the specified playback position.
2173     * @since 8
2174     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2175     * @param timeMs Playback position to jump
2176     * @param mode seek mode, see @SeekMode .
2177     * @returns A Promise instance used to return when seek completed
2178     * and return the seeking position result.
2179     * @deprecated since 9
2180     * @useinstead ohos.multimedia.media/media.AVPlayer#seek
2181     */
2182    seek(timeMs: number, mode?:SeekMode): Promise<number>;
2183    /**
2184     * Sets the volume.
2185     * @since 8
2186     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2187     * @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%).
2188     * @param callback A callback instance used to return when set volume completed.
2189     * @deprecated since 9
2190     * @useinstead ohos.multimedia.media/media.AVPlayer#setVolume
2191     */
2192    setVolume(vol: number, callback: AsyncCallback<void>): void;
2193    /**
2194     * Sets the volume.
2195     * @since 8
2196     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2197     * @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%).
2198     * @returns A Promise instance used to return when set volume completed.
2199     * @deprecated since 9
2200     * @useinstead ohos.multimedia.media/media.AVPlayer#setVolume
2201     */
2202    setVolume(vol: number): Promise<void>;
2203    /**
2204     * Releases resources used for video playback.
2205     * @since 8
2206     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2207     * @param callback A callback instance used to return when release completed.
2208     * @deprecated since 9
2209     * @useinstead ohos.multimedia.media/media.AVPlayer#release
2210     */
2211    release(callback: AsyncCallback<void>): void;
2212    /**
2213     * Releases resources used for video playback.
2214     * @since 8
2215     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2216     * @returns A Promise instance used to return when release completed.
2217     * @deprecated since 9
2218     * @useinstead ohos.multimedia.media/media.AVPlayer#release
2219     */
2220    release(): Promise<void>;
2221    /**
2222     * Get all track infos in MediaDescription, should be called after data loaded callback.
2223     * @since 8
2224     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2225     * @param callback async callback return track info in MediaDescription.
2226     * @deprecated since 9
2227     * @useinstead ohos.multimedia.media/media.AVPlayer#getTrackDescription
2228     */
2229    getTrackDescription(callback: AsyncCallback<Array<MediaDescription>>): void;
2230
2231    /**
2232     * Get all track infos in MediaDescription, should be called after data loaded callback.
2233     * @since 8
2234     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2235     * @returns A Promise instance used to return the track info in MediaDescription.
2236     * @deprecated since 9
2237     * @useinstead ohos.multimedia.media/media.AVPlayer#getTrackDescription
2238     */
2239    getTrackDescription() : Promise<Array<MediaDescription>>;
2240
2241    /**
2242     * media url. Mainstream video formats are supported.
2243     * local:fd://XXX, file://XXX. network:http://xxx
2244     * @since 8
2245     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2246     * @deprecated since 9
2247     * @useinstead ohos.multimedia.media/media.AVPlayer#url
2248     */
2249    url: string;
2250
2251    /**
2252     * Video file descriptor. Mainstream video formats are supported.
2253     * @since 9
2254     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2255     * @deprecated since 9
2256     * @useinstead ohos.multimedia.media/media.AVPlayer#fdSrc
2257     */
2258    fdSrc: AVFileDescriptor;
2259
2260    /**
2261     * Whether to loop video playback. The value true means to loop playback.
2262     * @since 8
2263     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2264     * @deprecated since 9
2265     * @useinstead ohos.multimedia.media/media.AVPlayer#loop
2266     */
2267    loop: boolean;
2268
2269    /**
2270     * Current playback position.
2271     * @since 8
2272     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2273     * @deprecated since 9
2274     * @useinstead ohos.multimedia.media/media.AVPlayer#currentTime
2275     */
2276    readonly currentTime: number;
2277
2278    /**
2279     * Playback duration, if -1 means cannot seek.
2280     * @since 8
2281     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2282     * @deprecated since 9
2283     * @useinstead ohos.multimedia.media/media.AVPlayer#duration
2284     */
2285    readonly duration: number;
2286
2287    /**
2288     * Playback state.
2289     * @since 8
2290     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2291     * @deprecated since 9
2292     * @useinstead ohos.multimedia.media/media.AVPlayer#state
2293     */
2294    readonly state: VideoPlayState;
2295
2296    /**
2297     * video width, valid after prepared.
2298     * @since 8
2299     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2300     * @deprecated since 9
2301     * @useinstead ohos.multimedia.media/media.AVPlayer#width
2302     */
2303    readonly width: number;
2304
2305    /**
2306     * video height, valid after prepared.
2307     * @since 8
2308     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2309     * @deprecated since 9
2310     * @useinstead ohos.multimedia.media/media.AVPlayer#height
2311     */
2312    readonly height: number;
2313
2314    /**
2315     * Describes audio interrupt mode, refer to {@link #audio.InterruptMode}. If it is not
2316     * set, the default mode will be used. Set it before calling the {@link #play()} in the
2317     * first time in order for the interrupt mode to become effective thereafter.
2318     * @since 9
2319     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2320     * @deprecated since 9
2321     * @useinstead ohos.multimedia.media/media.AVPlayer#audioInterruptMode
2322     */
2323    audioInterruptMode ?: audio.InterruptMode;
2324
2325    /**
2326     * video scale type. By default, the {@link #VIDEO_SCALE_TYPE_FIT_CROP} will be used, for more
2327     * information, refer to {@link #VideoScaleType}
2328     * @since 9
2329     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2330     * @deprecated since 9
2331     * @useinstead ohos.multimedia.media/media.AVPlayer#videoScaleType
2332     */
2333    videoScaleType ?: VideoScaleType;
2334
2335    /**
2336     * set payback speed.
2337     * @since 8
2338     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2339     * @param speed playback speed, see @PlaybackSpeed .
2340     * @param callback Callback used to return actually speed.
2341     * @deprecated since 9
2342     * @useinstead ohos.multimedia.media/media.AVPlayer#setSpeed
2343     */
2344    setSpeed(speed:number, callback: AsyncCallback<number>): void;
2345    /**
2346     * set output surface.
2347     * @since 8
2348     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2349     * @param speed playback speed, see @PlaybackSpeed .
2350     * @returns A Promise instance used to return actually speed.
2351     * @deprecated since 9
2352     * @useinstead ohos.multimedia.media/media.AVPlayer#setSpeed
2353     */
2354    setSpeed(speed:number): Promise<number>;
2355
2356    /**
2357     * Listens for video playback completed events.
2358     * @since 8
2359     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2360     * @param type Type of the playback event to listen for.
2361     * @param callback Callback used to listen for the playback event return .
2362     * @deprecated since 9
2363     * @useinstead ohos.multimedia.media/media.AVPlayer#event:stateChange
2364     */
2365    on(type: 'playbackCompleted', callback: Callback<void>): void;
2366
2367    /**
2368     * Listens for video playback buffering events.
2369     * @since 8
2370     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2371     * @param type Type of the playback buffering update event to listen for.
2372     * @param callback Callback used to listen for the buffering update event, return BufferingInfoType and the value.
2373     * @deprecated since 9
2374     * @useinstead ohos.multimedia.media/media.AVPlayer#event:bufferingUpdate
2375     */
2376    on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void;
2377
2378    /**
2379     * Listens for start render video frame events.
2380     * @since 8
2381     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2382     * @param type Type of the playback event to listen for.
2383     * @param callback Callback used to listen for the playback event return.
2384     * @deprecated since 9
2385     * @useinstead ohos.multimedia.media/media.AVPlayer#event:startRenderFrame
2386     */
2387    on(type: 'startRenderFrame', callback: Callback<void>): void;
2388
2389    /**
2390     * Listens for video size changed event.
2391     * @since 8
2392     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2393     * @param type Type of the playback event to listen for.
2394     * @param callback Callback used to listen for the playback event return video size.
2395     * @deprecated since 9
2396     * @useinstead ohos.multimedia.media/media.AVPlayer#event:videoSizeChange
2397     */
2398    on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): void;
2399
2400    /**
2401     * Listens for audio interrupt event, refer to {@link #audio.InterruptEvent}
2402     * @since 9
2403     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2404     * @param type Type of the playback event to listen for.
2405     * @param callback Callback used to listen for the playback event return audio interrupt info.
2406     * @deprecated since 9
2407     * @useinstead ohos.multimedia.media/media.AVPlayer#event:audioInterrupt
2408     */
2409    on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void;
2410
2411    /**
2412     * Listens for playback error events.
2413     * @since 8
2414     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2415     * @param type Type of the playback error event to listen for.
2416     * @param callback Callback used to listen for the playback error event.
2417     * @deprecated since 9
2418     * @useinstead ohos.multimedia.media/media.AVPlayer#event:error
2419     */
2420    on(type: 'error', callback: ErrorCallback): void;
2421  }
2422
2423  /**
2424   * Enumerates video scale type.
2425   * @since 9
2426   * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2427   */
2428  enum VideoScaleType {
2429    /**
2430     * The content is stretched to the fit the display surface rendering area. When
2431     * the aspect ratio of the content is not same as the display surface, the aspect
2432     * of the content is not maintained. This is the default scale type.
2433     * @since 9
2434     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2435     */
2436    VIDEO_SCALE_TYPE_FIT = 0,
2437
2438    /**
2439     * The content is stretched to the fit the display surface rendering area. When
2440     * the aspect ratio of the content is not the same as the display surface, content's
2441     * aspect ratio is maintained and the content is cropped to fit the display surface.
2442     * @since 9
2443     * @syscap SystemCapability.Multimedia.Media.VideoPlayer
2444     */
2445    VIDEO_SCALE_TYPE_FIT_CROP = 1,
2446  }
2447
2448  /**
2449   * Enumerates container format type(The abbreviation for 'container format type' is CFT).
2450   * @since 8
2451   * @syscap SystemCapability.Multimedia.Media.Core
2452   */
2453  enum ContainerFormatType {
2454    /**
2455     * A video container format type mp4.
2456     * @since 8
2457     * @syscap SystemCapability.Multimedia.Media.Core
2458     */
2459    CFT_MPEG_4 = "mp4",
2460
2461    /**
2462     * A audio container format type m4a.
2463     * @since 8
2464     * @syscap SystemCapability.Multimedia.Media.Core
2465     */
2466    CFT_MPEG_4A = "m4a",
2467  }
2468
2469  /**
2470   * Enumerates media data type.
2471   * @since 8
2472   * @syscap SystemCapability.Multimedia.Media.Core
2473   */
2474  enum MediaType {
2475    /**
2476     * track is audio.
2477     * @since 8
2478     * @syscap SystemCapability.Multimedia.Media.Core
2479     */
2480    MEDIA_TYPE_AUD = 0,
2481    /**
2482     * track is video.
2483     * @since 8
2484     * @syscap SystemCapability.Multimedia.Media.Core
2485     */
2486    MEDIA_TYPE_VID = 1,
2487  }
2488
2489  /**
2490   * Enumerates media description key.
2491   * @since 8
2492   * @syscap SystemCapability.Multimedia.Media.Core
2493   */
2494  enum MediaDescriptionKey {
2495    /**
2496     * key for track index, value type is number.
2497     * @since 8
2498     * @syscap SystemCapability.Multimedia.Media.Core
2499     */
2500    MD_KEY_TRACK_INDEX = "track_index",
2501
2502    /**
2503     * key for track type, value type is number, see @MediaType.
2504     * @since 8
2505     * @syscap SystemCapability.Multimedia.Media.Core
2506     */
2507    MD_KEY_TRACK_TYPE = "track_type",
2508
2509    /**
2510     * key for codec mime type, value type is string.
2511     * @since 8
2512     * @syscap SystemCapability.Multimedia.Media.Core
2513     */
2514    MD_KEY_CODEC_MIME = "codec_mime",
2515
2516    /**
2517     * key for duration, value type is number.
2518     * @since 8
2519     * @syscap SystemCapability.Multimedia.Media.Core
2520     */
2521    MD_KEY_DURATION = "duration",
2522
2523    /**
2524     * key for bitrate, value type is number.
2525     * @since 8
2526     * @syscap SystemCapability.Multimedia.Media.Core
2527     */
2528    MD_KEY_BITRATE = "bitrate",
2529
2530    /**
2531     * key for video width, value type is number.
2532     * @since 8
2533     * @syscap SystemCapability.Multimedia.Media.Core
2534     */
2535    MD_KEY_WIDTH = "width",
2536
2537    /**
2538     * key for video height, value type is number.
2539     * @since 8
2540     * @syscap SystemCapability.Multimedia.Media.Core
2541     */
2542    MD_KEY_HEIGHT = "height",
2543
2544    /**
2545     * key for video frame rate, value type is number.
2546     * @since 8
2547     * @syscap SystemCapability.Multimedia.Media.Core
2548     */
2549    MD_KEY_FRAME_RATE = "frame_rate",
2550
2551    /**
2552     * key for audio channel count, value type is number
2553     * @since 8
2554     * @syscap SystemCapability.Multimedia.Media.Core
2555     */
2556    MD_KEY_AUD_CHANNEL_COUNT = "channel_count",
2557
2558    /**
2559     * key for audio sample rate, value type is number
2560     * @since 8
2561     * @syscap SystemCapability.Multimedia.Media.Core
2562     */
2563    MD_KEY_AUD_SAMPLE_RATE = "sample_rate",
2564  }
2565
2566  /**
2567   * Provides the video recorder profile definitions.
2568   * @since 9
2569   * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2570   * @systemapi
2571   */
2572  interface VideoRecorderProfile {
2573    /**
2574     * Indicates the audio bit rate.
2575     * @since 9
2576     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2577     * @systemapi
2578     */
2579    readonly audioBitrate: number;
2580
2581    /**
2582     * Indicates the number of audio channels.
2583     * @since 9
2584     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2585     * @systemapi
2586     */
2587    readonly audioChannels: number;
2588
2589    /**
2590     * Indicates the audio encoding format.
2591     * @since 9
2592     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2593     * @systemapi
2594     */
2595    readonly audioCodec: CodecMimeType;
2596
2597    /**
2598     * Indicates the audio sampling rate.
2599     * @since 9
2600     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2601     * @systemapi
2602     */
2603    readonly audioSampleRate: number;
2604
2605    /**
2606     * Indicates the output file format.
2607     * @since 9
2608     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2609     * @systemapi
2610     */
2611    readonly fileFormat: ContainerFormatType;
2612
2613    /**
2614     * Indicates the video bit rate.
2615     * @since 9
2616     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2617     * @systemapi
2618     */
2619    readonly videoBitrate: number;
2620
2621    /**
2622     * Indicates the video encoding format.
2623     * @since 9
2624     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2625     * @systemapi
2626     */
2627    readonly videoCodec: CodecMimeType;
2628
2629    /**
2630     * Indicates the video width.
2631     * @since 9
2632     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2633     * @systemapi
2634     */
2635    readonly videoFrameWidth: number;
2636
2637    /**
2638     * Indicates the video height.
2639     * @since 9
2640     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2641     * @systemapi
2642     */
2643    readonly videoFrameHeight: number;
2644
2645    /**
2646     * Indicates the video frame rate.
2647     * @since 9
2648     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2649     * @systemapi
2650     */
2651    readonly videoFrameRate: number;
2652  }
2653
2654  /**
2655   * Enumerates audio source type for recorder.
2656   * @since 9
2657   * @syscap SystemCapability.Multimedia.Media.AVRecorder
2658   */
2659  enum AudioSourceType {
2660    /**
2661     * Default audio source type.
2662     * @since 9
2663     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2664     */
2665    AUDIO_SOURCE_TYPE_DEFAULT = 0,
2666    /**
2667     * Source type mic.
2668     * @since 9
2669     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2670     */
2671    AUDIO_SOURCE_TYPE_MIC = 1,
2672  }
2673
2674  /**
2675   * Enumerates video source type for recorder.
2676   * @since 9
2677   * @syscap SystemCapability.Multimedia.Media.AVRecorder
2678   */
2679  enum VideoSourceType {
2680    /**
2681     * Surface raw data.
2682     * @since 9
2683     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2684     */
2685    VIDEO_SOURCE_TYPE_SURFACE_YUV = 0,
2686    /**
2687     * Surface ES data.
2688     * @since 9
2689     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2690     */
2691    VIDEO_SOURCE_TYPE_SURFACE_ES = 1,
2692  }
2693
2694  /**
2695   * Provides the video recorder configuration definitions.
2696   * @since 9
2697   * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2698   * @systemapi
2699   */
2700  interface VideoRecorderConfig {
2701    /**
2702     * audio source type, details see @AudioSourceType .
2703     * @since 9
2704     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2705     * @systemapi
2706     */
2707    audioSourceType?: AudioSourceType;
2708    /**
2709     * video source type, details see @VideoSourceType .
2710     * @since 9
2711     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2712     * @systemapi
2713     */
2714    videoSourceType: VideoSourceType;
2715    /**
2716     * video recorder profile, can get by "getVideoRecorderProfile", details see @VideoRecorderProfile .
2717     * @since 9
2718     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2719     * @systemapi
2720     */
2721    profile: VideoRecorderProfile;
2722    /**
2723     * video output uri.support two kind of uri now.
2724     * format like: scheme + "://" + "context".
2725     * fd:    fd://fd
2726     * @since 9
2727     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2728     * @systemapi
2729     */
2730    url: string;
2731    /**
2732     * Sets the video rotation angle in output file, and for the file to playback. mp4 support.
2733     * the range of rotation angle should be {0, 90, 180, 270}, default is 0.
2734     * @since 9
2735     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2736     * @systemapi
2737     */
2738    rotation?: number;
2739    /**
2740     * geographical location information.
2741     * @since 9
2742     * @syscap SystemCapability.Multimedia.Media.VideoRecorder
2743     * @systemapi
2744     */
2745    location?: Location;
2746  }
2747
2748  /**
2749   * Provides the media recorder profile definitions.
2750   * @since 9
2751   * @syscap SystemCapability.Multimedia.Media.AVRecorder
2752   */
2753   interface AVRecorderProfile {
2754    /**
2755     * Indicates the audio bitrate.
2756     * @since 9
2757     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2758     */
2759    audioBitrate?: number;
2760
2761    /**
2762     * Indicates the number of audio channels.
2763     * @since 9
2764     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2765     */
2766    audioChannels?: number;
2767
2768    /**
2769     * Indicates the audio encoding format.
2770     * @since 9
2771     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2772     */
2773    audioCodec?: CodecMimeType;
2774
2775    /**
2776     * Indicates the audio sampling rate.
2777     * @since 9
2778     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2779     */
2780    audioSampleRate?: number;
2781
2782    /**
2783     * Indicates the output file format.
2784     * @since 9
2785     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2786     */
2787    fileFormat: ContainerFormatType;
2788
2789    /**
2790     * Indicates the video bitrate.
2791     * @since 9
2792     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2793     */
2794    videoBitrate?: number;
2795
2796    /**
2797     * Indicates the video encoding format.
2798     * @since 9
2799     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2800     */
2801    videoCodec?: CodecMimeType;
2802
2803    /**
2804     * Indicates the video width.
2805     * @since 9
2806     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2807     */
2808    videoFrameWidth?: number;
2809
2810    /**
2811     * Indicates the video height.
2812     * @since 9
2813     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2814     */
2815    videoFrameHeight?: number;
2816
2817    /**
2818     * Indicates the video frame rate.
2819     * @since 9
2820     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2821     */
2822    videoFrameRate?: number;
2823  }
2824
2825  /**
2826   * Provides the media recorder configuration definitions.
2827   * @since 9
2828   * @syscap SystemCapability.Multimedia.Media.AVRecorder
2829   */
2830  interface AVRecorderConfig {
2831    /**
2832     * Audio source type, details see @AudioSourceType .
2833     * @since 9
2834     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2835     */
2836    audioSourceType?: AudioSourceType;
2837    /**
2838     * Video source type, details see @VideoSourceType .
2839     * @since 9
2840     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2841     */
2842    videoSourceType?: VideoSourceType;
2843    /**
2844     * Video recorder profile, details see @AVRecorderProfile .
2845     * @since 9
2846     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2847     */
2848    profile: AVRecorderProfile;
2849    /**
2850     * File output uri, support a kind of uri now.
2851     * format like: "fd://" + "context".
2852     * @since 9
2853     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2854     */
2855    url: string;
2856    /**
2857     * Sets the video rotation angle in output file, and for the file to playback, mp4 support
2858     * the range of rotation angle should be {0, 90, 180, 270}, default is 0.
2859     * @since 9
2860     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2861     */
2862    rotation?: number;
2863    /**
2864     * Geographical location information.
2865     * @since 9
2866     * @syscap SystemCapability.Multimedia.Media.AVRecorder
2867     */
2868    location?: Location;
2869  }
2870
2871  /**
2872   * Provides the container definition for media description key-value pairs.
2873   * @since 8
2874   * @syscap SystemCapability.Multimedia.Media.Core
2875   */
2876  interface MediaDescription {
2877    /**
2878     * key:value pair, key see @MediaDescriptionKey .
2879     * @since 8
2880     * @syscap SystemCapability.Multimedia.Media.Core
2881     */
2882    [key : string]: Object;
2883  }
2884
2885  /**
2886   * Enumerates seek mode.
2887   * @since 8
2888   * @syscap SystemCapability.Multimedia.Media.Core
2889   */
2890  enum SeekMode {
2891    /**
2892     * seek to the next sync frame of the given timestamp
2893     * @since 8
2894     * @syscap SystemCapability.Multimedia.Media.Core
2895     */
2896    SEEK_NEXT_SYNC = 0,
2897    /**
2898     * seek to the previous sync frame of the given timestamp
2899     * @since 8
2900     * @syscap SystemCapability.Multimedia.Media.Core
2901     */
2902    SEEK_PREV_SYNC = 1,
2903  }
2904
2905  /**
2906   * Enumerates Codec MIME types.
2907   * @since 8
2908   * @syscap SystemCapability.Multimedia.Media.Core
2909   */
2910   enum CodecMimeType {
2911    /**
2912     * H.263 codec MIME type.
2913     * @since 8
2914     * @syscap SystemCapability.Multimedia.Media.Core
2915     */
2916    VIDEO_H263 = 'video/h263',
2917    /**
2918     * H.264 codec MIME type.
2919     * @since 8
2920     * @syscap SystemCapability.Multimedia.Media.Core
2921     */
2922    VIDEO_AVC = 'video/avc',
2923    /**
2924     * MPEG2 codec MIME type.
2925     * @since 8
2926     * @syscap SystemCapability.Multimedia.Media.Core
2927     */
2928    VIDEO_MPEG2 = 'video/mpeg2',
2929    /**
2930     * MPEG4 codec MIME type
2931     * @since 8
2932     * @syscap SystemCapability.Multimedia.Media.Core
2933     */
2934    VIDEO_MPEG4 = 'video/mp4v-es',
2935
2936    /**
2937     * VP8 codec MIME type
2938     * @since 8
2939     * @syscap SystemCapability.Multimedia.Media.Core
2940     */
2941    VIDEO_VP8 = 'video/x-vnd.on2.vp8',
2942
2943    /**
2944     * AAC codec MIME type.
2945     * @since 8
2946     * @syscap SystemCapability.Multimedia.Media.Core
2947     */
2948    AUDIO_AAC = 'audio/mp4a-latm',
2949
2950    /**
2951     * vorbis codec MIME type.
2952     * @since 8
2953     * @syscap SystemCapability.Multimedia.Media.Core
2954     */
2955    AUDIO_VORBIS = 'audio/vorbis',
2956
2957    /**
2958     * flac codec MIME type.
2959     * @since 8
2960     * @syscap SystemCapability.Multimedia.Media.Core
2961     */
2962    AUDIO_FLAC = 'audio/flac',
2963  }
2964}
2965export default media;
2966