diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index d6f0a0353e7177c57203f20e1b8827c96ccdc833..f319e37cedb8a271705c034cc185642bb52c55b9 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -66,6 +66,24 @@ declare namespace audio { */ function createAudioRenderer(options: AudioRendererOptions): Promise; + /** + * Obtains a TonePlayer instance. This method uses an asynchronous callback to return the renderer instance. + * @param options Tone playing attribute. + * @return Promise used to return the tone player instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + function createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback): void; + + /** + * Obtains a TonePlayer instance. This method uses a promise to return the renderer instance. + * @param options Tone playing attribute. + * @return Promise used to return the tone player instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + function createTonePlayer(options: AudioRendererInfo): Promise; + /** * Enumerates the audio states. * @since 8 @@ -1198,6 +1216,183 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Renderer */ off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback): void; + + /** + * Obtains an AudioStreamManager instance. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + getStreamManager(callback: AsyncCallback): void; + + /** + * Obtains an AudioStreamManager instance. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + getStreamManager(): Promise; + } + + /** + * Implements audio stream management. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + interface AudioStreamManager { + /** + * Get infos of current existing audio renderers. + * @param callback Callback used to return the infos of current existing audio renderers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioRendererInfos(callback: AsyncCallback): void; + + /** + * Get infos of current existing audio renderers. + * @return Promise used to return the infos of current existing audio renderers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioRendererInfos(): Promise; + + /** + * Get infos of current existing audio capturers. + * @param callback Callback used to return the infos of current existing audio capturers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioCapturerInfos(callback: AsyncCallback): void; + + /** + * Get infos of current existing audio capturers. + * @return Promise used to return the infos of current existing audio capturers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioCapturerInfos(): Promise; + + /** + * Listens for audio renderer change events. When there is any audio renderer change, + * registered clients will receive the callback. + * @param type Type of the event to listen for. Only the audioRendererChange event is supported. + * @param callback Callback invoked for the audio renderer change event. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: "audioRendererChange", callback: Callback): void; + + /** + * UnSubscribes to audio renderer change events. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + off(type: "audioRendererChange"); + + /** + * Listens for audio capturer change events. When there is any audio capturer change, + * registered clients will receive the callback. + * @param type Type of the event to listen for. Only the audioCapturerChange event is supported. + * @param callback Callback invoked for the audio capturer change event. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + on(type: "audioCapturerChange", callback: Callback): void; + + /** + * UnSubscribes to audio capturer change events. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + off(type: "audioCapturerChange"); + } + + /** + * Array of AudioRendererChangeInfo, which is read-only. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + type AudioRendererChangeInfos = Array>; + + /** + * Describes audio renderer change information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface AudioRendererChangeInfo { + /** + * Audio stream unique id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly streamId: number; + + /** + * Uid for audio renderer client application. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @systemapi + */ + readonly clientUid: number; + + /** + * Audio renderer information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly rendererInfo: AudioRendererInfo; + + /** + * Audio state. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @systemapi + */ + readonly rendererState: AudioState; + } + + /** + * Array of AudioCapturerChangeInfo, which is read-only. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + type AudioCapturerChangeInfos = Array>; + + /** + * Describes audio capturer change information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + interface AudioCapturerChangeInfo { + /** + * Audio stream unique id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly streamId: number; + + /** + * Uid for audio capturer client application. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @systemapi + */ + readonly clientUid: number; + + /** + * Audio capturer information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly capturerInfo: AudioCapturerInfo; + + /** + * Audio state. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @systemapi + */ + readonly capturerState: AudioState; } /** @@ -1828,6 +2023,98 @@ declare namespace audio { */ on(type: "stateChange", callback: Callback): void; } + + enum ToneType { + TONE_TYPE_DIAL_0 = 0, // 0 key + TONE_TYPE_DIAL_1, // 1 key + TONE_TYPE_DIAL_2, // 2 key + TONE_TYPE_DIAL_3, // 3 key + TONE_TYPE_DIAL_4, // 4 key + TONE_TYPE_DIAL_5, // 5 key + TONE_TYPE_DIAL_6, // 6 key + TONE_TYPE_DIAL_7, // 7 key + TONE_TYPE_DIAL_8, // 8 key + TONE_TYPE_DIAL_9, // 9 key + TONE_TYPE_DIAL_S, // * key + TONE_TYPE_DIAL_P, // # key + TONE_TYPE_DIAL_A, // A key + TONE_TYPE_DIAL_B, // B key + TONE_TYPE_DIAL_C, // C key + TONE_TYPE_DIAL_D, // D key + + TONE_TYPE_CALL_SUP_DIAL = 100, + + TONE_TYPE_CALL_PROP_BEEP = 200, + } + + /** + * Provides APIs for tone playing. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + interface TonePlayer { + /** + * Starts player. This method uses an asynchronous callback to return the result. + * @param type Tone type to play. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + load(type: ToneType, callback: AsyncCallback): void; + /** + * Starts tplayerone. This method uses a promise to return the result. + * @param type Tone type to play. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + load(type: ToneType): Promise; + + /** + * Starts player. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + start(callback: AsyncCallback): void; + /** + * Starts player. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + start(): Promise; + + /** + * Stops player. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + stop(callback: AsyncCallback): void; + /** + * Stops player. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + stop(): Promise; + + /** + * Releases the player. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + release(callback: AsyncCallback): void; + /** + * Releases the player. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + release(): Promise; + } } export default audio;