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