```js
/**
* Creates an AVPlayer instance.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param callback Callback used to return AVPlayer instance if the operation is successful; returns null otherwise.
* @throws { BusinessError } 5400101 - No memory. Return by callback.
*/
function createAVPlayer(callback: AsyncCallback<AVPlayer>): void;
/**
* Creates an AVPlayer instance.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @returns A Promise instance used to return AVPlayer instance if the operation is successful; returns null otherwise.
* @throws { BusinessError } 5400101 - No memory. Return by promise.
*/
function createAVPlayer() : Promise<AVPlayer>;
```
```js
/**
* Prepare audio/video playback, it will request resource for playing.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param callback A callback instance used to return when prepare completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
* @throws { BusinessError } 5400106 - Unsupport format. Return by callback.
*/
prepare(callback: AsyncCallback<void>): void;
/**
* Prepare audio/video playback, it will request resource for playing.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @returns A Promise instance used to return when prepare completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
* @throws { BusinessError } 5400106 - Unsupport format. Return by promise.
*/
prepare(): Promise<void>;
/**
* Play audio/video playback.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param callback A callback instance used to return when play completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
*/
play(callback: AsyncCallback<void>): void;
/**
* Play audio/video playback.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @returns A Promise instance used to return when play completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
*/
play(): Promise<void>;
/**
* Pause audio/video playback.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param callback A callback instance used to return when pause completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
*/
pause(callback: AsyncCallback<void>): void;
/**
* Pause audio/video playback.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @returns A Promise instance used to return when pause completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
*/
pause(): Promise<void>;
/**
* Stop audio/video playback.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param callback A callback instance used to return when stop completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
*/
stop(callback: AsyncCallback<void>): void;
/**
* Stop audio/video playback.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @returns A Promise instance used to return when stop completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
*/
stop(): Promise<void>;
/**
* Reset AVPlayer, it will to idle state and can set src again.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param callback A callback instance used to return when reset completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
*/
reset(callback: AsyncCallback<void>): void;
/**
* Reset AVPlayer, it will to idle state and can set src again.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @returns A Promise instance used to return when reset completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
*/
reset(): Promise<void>;
/**
* Releases resources used for AVPlayer.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param callback A callback instance used to return when release completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by callback.
*/
release(callback: AsyncCallback<void>): void;
/**
* Releases resources used for AVPlayer.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @returns A Promise instance used to return when release completed.
* @throws { BusinessError } 5400102 - Operation not allowed. Return by promise.
*/
release(): Promise<void>;
/**
* Jumps to the specified playback position.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param timeMs Playback position to jump, should be in [0, duration].
* @param mode See @SeekMode .
*/
seek(timeMs: number, mode?:SeekMode): void;
```
*
* 其他回调接口
```js
/**
* Register or unregister listens for media playback events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback stateChange event.
*/
on(type: 'stateChange', callback: (state: AVPlayerState, reason: StateChangeReason) => void): void;
off(type: 'stateChange'): void;
/**
* Register or unregister listens for media playback events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback volume event.
*/
on(type: 'volumeChange', callback: Callback<number>): void;
off(type: 'volumeChange'): void;
/**
* Register or unregister listens for media playback events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback end of stream
*/
on(type: 'endOfStream', callback: Callback<void>): void;
off(type: 'endOfStream'): void;
/**
* Register or unregister listens for media playback events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback seekDone event.
*/
on(type: 'seekDone', callback: Callback<number>): void;
off(type: 'seekDone'): void;
/**
* Register or unregister listens for media playback events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback speedDone event.
*/
on(type: 'speedDone', callback: Callback<number>): void;
off(type: 'speedDone'): void;
/**
* Register or unregister listens for media playback events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback setBitrateDone event.
*/
on(type: 'bitrateDone', callback: Callback<number>): void;
off(type: 'bitrateDone'): void;
/**
* LRegister or unregister listens for media playback events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback timeUpdate event.
*/
on(type: 'timeUpdate', callback: Callback<number>): void;
off(type: 'timeUpdate'): void;
/**
* Register or unregister listens for media playback events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback durationUpdate event.
*/
on(type: 'durationUpdate', callback: Callback<number>): void;
off(type: 'durationUpdate'): void;
/**
* Register or unregister listens for video playback buffering events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback buffering update event to listen for.
* @param callback Callback used to listen for the buffering update event, return BufferingInfoType and the value.
*/
on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void;
off(type: 'bufferingUpdate'): void;
/**
* Register or unregister listens for start render video frame events.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback event return .
*/
on(type: 'startRenderFrame', callback: Callback<void>): void;
off(type: 'startRenderFrame'): void;
/**
* Register or unregister listens for video size change event.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback event return video size.
*/
on(type: 'videoSizeChange', callback: (width: number, height: number) => void): void;
off(type: 'videoSizeChange'): void;
/**
* Register or unregister listens for audio interrupt event, refer to {@link #audio.InterruptEvent}
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback event return audio interrupt info.
*/
on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void;
off(type: 'audioInterrupt'): void;
/**
* Register or unregister listens for available bitrate list collect completed events for HLS protocol stream playback.
* This event will be reported after the {@link #prepare} called.
* @since 9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @param type Type of the playback event to listen for.
* @param callback Callback used to listen for the playback event return available bitrate list.
*/
on(type: 'availableBitrates', callback: (bitrates: Array<number>) => void): void;
off(type: 'availableBitrates'): void;
```
*