diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index bd12578b0d250ee1a595c9a380385dbe47c88416..4d2d670d576c55f7f2fe59b5328fb312f650f969 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -1007,6 +1007,30 @@ declare namespace audio { SPEAKER = 2 } + /** + * Enumerates the device select strategy. + * @enum { number } + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + * @since 21 + */ + enum AudioDevcieSelectStrategy { + /** + * The default follow device select strategy. + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + * @since 21 + */ + SELECT_STRATEGY_DEFAULT = 0, + /** + * The independent device select strategy.. + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + * @since 21 + */ + SELECT_STRATEGY_INDEPENDENT = 1, + } + /** * Enumerates ringer modes. * @enum { number } @@ -3721,6 +3745,21 @@ declare namespace audio { */ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise; + /** + * Select the output device with desired AudioRenderer. This method uses a promise to return the result. + * @param { AudioRendererFilter } filter - Filter for AudioRenderer. + * @param { AudioDeviceDescriptors } outputAudioDevices - Audio device description. + * @param { AudioDevcieSelectStrategy } strategy - Audio device select strategy. + * @returns { Promise } Promise used to return the result. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @throws { BusinessError } 6800301 - Audio client call audio service error, System error. + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + * @since 21 + */ + selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, strategy: AudioDevcieSelectStrategy): Promise; + /** * Select the input device. This method uses an asynchronous callback to return the result. * @param { AudioDeviceDescriptors } inputAudioDevices - Audio device description @@ -3900,6 +3939,35 @@ declare namespace audio { */ off(type: 'preferOutputDeviceChangeForRendererInfo', callback?: Callback): void; + /** + * Subscribes to prefer output device change events. When prefer device for target audio renderer info changes, + * registered clients will receive the callback. + * @param { 'preferOutputDeviceChangeByFilter' } type - Type of the event to listen for. Only the + * preferOutputDeviceChangeByFilter event is supported. + * @param { AudioRendererFilter } filter - Filter for AudioRenderer. + * @param { Callback } callback - Callback used to obtain the changed prefer devices information. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @throws { BusinessError } 6800301 - Audio client call audio service error, System error. + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + * @since 21 + */ + on(type: 'preferredOutputDeviceChangeByFilter', filter: AudioRendererFilter, callback: Callback): void; + + /** + * UnSubscribes to prefer output device change events. + * @param { 'preferOutputDeviceChangeByFilter' } type - Type of the event to listen for. Only the + * preferOutputDeviceChangeByFilter event is supported. + * @param { Callback } [callback] - Callback used to obtain the changed prefer devices in subscribe. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800301 - Audio client call audio service error, System error. + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + * @since 21 + */ + off(type: 'preferredOutputDeviceChangeByFilter', callback?: Callback): void; + /** * Get input device for target audio capturer info. * @param { AudioCapturerInfo } capturerInfo - Audio capturer information.