From 63c605b1399826a76226019d697d1c8107bda2c4 Mon Sep 17 00:00:00 2001 From: magekkkk Date: Tue, 10 May 2022 08:13:59 +0000 Subject: [PATCH 1/4] add tone api Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index d6f0a0353e..82d911a818 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 @@ -1828,6 +1846,79 @@ declare namespace audio { */ on(type: "stateChange", callback: Callback): void; } + + enum ToneType { + + } + + /** + * 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; -- Gitee From 69d0a3dbfbda468fa5235dac461303f6235eabf3 Mon Sep 17 00:00:00 2001 From: magekkkk Date: Thu, 12 May 2022 12:52:54 +0000 Subject: [PATCH 2/4] add stream listener api Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 154 ++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 82d911a818..13916a1320 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -1216,6 +1216,160 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Renderer */ off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback): void; + + /** + * 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 { + /** + * Session id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly sessionId: 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 { + /** + * Session id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly sessionId: 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; } /** -- Gitee From 4cfb9df16a4380c4d929fbee8bc3fc37d60f0613 Mon Sep 17 00:00:00 2001 From: magekkkk Date: Fri, 20 May 2022 02:55:16 +0000 Subject: [PATCH 3/4] add some tonetypes Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 13916a1320..3789977400 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -2002,7 +2002,26 @@ declare namespace audio { } 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, } /** -- Gitee From 5c15ab3924a6a9e38f88aa7ebefe75da89abcc7e Mon Sep 17 00:00:00 2001 From: magekkkk Date: Mon, 23 May 2022 14:40:12 +0800 Subject: [PATCH 4/4] rename sessionid to streamid Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 3789977400..f319e37ced 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -1217,6 +1217,29 @@ declare namespace audio { */ 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. @@ -1298,11 +1321,11 @@ declare namespace audio { */ interface AudioRendererChangeInfo { /** - * Session id. + * Audio stream unique id. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ - readonly sessionId: number; + readonly streamId: number; /** * Uid for audio renderer client application. @@ -1342,11 +1365,11 @@ declare namespace audio { */ interface AudioCapturerChangeInfo { /** - * Session id. + * Audio stream unique id. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ - readonly sessionId: number; + readonly streamId: number; /** * Uid for audio capturer client application. -- Gitee