@ohos.multimedia.avInputCastPicker (AVInputCastPicker)

The module provides the functionality to create an AVInputCastPicker component, which offers a unified entry for discovering and connecting recording devices.

NOTE

  • The initial APIs of this module are supported since API version 20. Newly added APIs will be marked with a superscript to indicate their earliest API version.
  • The Preview in DevEco Studio does not support actual recording device selection. To see the real effect, test on a real device.
  • This component can only be used from the recording device selection screen, which needs to be implemented by OEM vendors.
  • This component can only be used on PCs.

Modules to Import

import { AVInputCastPicker } from '@kit.AVSessionKit';

Properties

The universal properties are supported.

AVInputCastPicker

AVInputCastPicker({
  customPicker?: CustomBuilder;
  onStateChange?: OnPickerStateCallback;
})

Implements an AVInputCastPicker component, which can be used to switch audio input devices.

This component is a custom component. Some basic knowledge of @Component will be helpful in using the component.

Decorator: @Component

Atomic service API: This API can be used in atomic services since API version 20.

System capability: SystemCapability.Multimedia.AVSession.AVInputCast

Parameters

Name Type Mandatory Decorator Description
customPicker CustomBuilder No @Prop Custom style. You are advised to customize a component style for higher component rendering performance.
onStateChange OnPickerStateCallback No - Callback invoked when the device list state changes.

OnPickerStateCallback

type OnPickerStateCallback = (state: AVCastPickerState) => void

Atomic service API: This API can be used in atomic services since API version 20.

System capability: SystemCapability.Multimedia.AVSession.AVInputCast

Parameters

Name Type Mandatory Description
state AVCastPickerState Yes Device list state.

Events

The universal events are supported.

Example

The following is an example of using AVCastPicker:

import { AVCastPickerState, AVInputCastPicker } from '@kit.AVSessionKit';

@Entry
@Component
struct Index {

  @State pickerImage: ResourceStr = $r('app.media.layered_image'); // Custom resources.

  private onStateChange(state: AVCastPickerState) {
    if (state == AVCastPickerState.STATE_APPEARING) {
      console.info('The picker starts showing.');
    } else if (state == AVCastPickerState.STATE_DISAPPEARING) {
      console.info('The picker finishes presenting.');
    }
  }

  @Builder
  customPickerBuilder() {
    Image(this.pickerImage)
      .width('100%')
      .height('100%')
      .fillColor(Color.Black)
  }

  build() {
    Row() {
      Column() {
        AVInputCastPicker({
          customPicker: () => this.customPickerBuilder(),
          onStateChange: this.onStateChange
        })
          .width('40vp')
          .height('40vp')
          .border({ width: 1, color: Color.Red })
      }.height('50%')
    }.width('50%')
  }
}