1e41f4b71Sopenharmony_ci# @ohos.multimedia.avCastPicker (AVCastPicker)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **AVCastPicker** component provides a unified entry for device discovery and connection.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> - You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer.<!--Del-->
9e41f4b71Sopenharmony_ci> - This component can only be used from the device selection screen, which needs to be implemented by OEM vendors.<!--DelEnd-->
10e41f4b71Sopenharmony_ci> <!--RP2--><!--RP2End-->
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## Modules to Import
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci```js
15e41f4b71Sopenharmony_ciimport { AVCastPicker } from '@kit.AVSessionKit';
16e41f4b71Sopenharmony_ci```
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci## AVCastPicker
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ciAVCastPicker()
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ciImplements an **AVCastPicker** component, which can be used to cast audio and video onto other devices.
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ciThis component is a custom component. Some basic knowledge of [@Component](../../quick-start/arkts-create-custom-components.md) will be helpful in using the component.
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.AVSession.AVCast
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci## Attributes
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ciIn addition to the [universal attributes](../apis-arkui/arkui-ts/ts-universal-attributes-size.md), the following attributes are supported.
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Decorator | Description |
35e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
36e41f4b71Sopenharmony_ci| normalColor<sup>11+</sup> | Color &#124; number &#124; string | No | @Prop | Color of the component in normal state.<br>If this parameter is left unspecified, the color setting in **colorMode** is used. |
37e41f4b71Sopenharmony_ci| activeColor<sup>11+</sup> | Color &#124; number &#124; string | No | @Prop | Color of the component when audio and video are successfully casted to another device. If this parameter is left unspecified, the system preferentially matches the color based on **normalColor**. If **normalColor** is also left unspecified, the color setting in **colorMode** is used. |
38e41f4b71Sopenharmony_ci| pickerStyle<sup>12+</sup> | [AVCastPickerStyle](js-apis-avCastPickerParam.md#avcastpickerstyle12) | No | @Prop | Style of the component.<br>- When **sessionType** is set to **audio** or **video**, the default value is **STYLE_PANEL**.<br>- When **sessionType** is set to **voice_call** or **video_call**, the default value is **STYLE_MENU** and the value cannot be changed to **STYLE_PANEL**.|
39e41f4b71Sopenharmony_ci| colorMode<sup>12+</sup> | [AVCastPickerColorMode](js-apis-avCastPickerParam.md#avcastpickercolormode12) | No |  @Prop | Display mode. The default value is **AUTO**.<br>- When **colorMode** is set to **AUTO**, the default system color in dark/light color mode is used.<br>- When **colorMode** is set to **DARK** or **LIGHT**, the preset system color of the corresponding mode is used. |
40e41f4b71Sopenharmony_ci| sessionType<sup>12+</sup> | string | No| @Prop | Session type. For details, see [AVSessionType](js-apis-avsession.md#avsessiontype10). The default value is **AVSessionType** created by the application. |
41e41f4b71Sopenharmony_ci| customPicker<sup>12+</sup> | [CustomBuilder](../apis-arkui/arkui-ts/ts-types.md#custombuilder8) | No | @Prop | Custom style. You are advised to customize a component style so that the component can be displayed quickly. |
42e41f4b71Sopenharmony_ci| onStateChange<sup>11+</sup> | (state: [AVCastPickerState](js-apis-avCastPickerParam.md)) => void | No | @Prop | Callback invoked when the casting state changes. |
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci## Events
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ciThe [universal events](../apis-arkui/arkui-ts/ts-universal-events-click.md) are supported.
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci## Example
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ciThe following is an example of using **AVCastPicker**:
51e41f4b71Sopenharmony_ci<!--RP1--><!--RP1End-->
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci```ts
54e41f4b71Sopenharmony_ciimport { AVCastPickerState, AVCastPicker } from '@kit.AVSessionKit';
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci@Entry
57e41f4b71Sopenharmony_ci@Component
58e41f4b71Sopenharmony_cistruct Index {
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci  @State pickerImage: ResourceStr = $r('app.media.castPicker'); // Custom resources.
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci  private onStateChange(state: AVCastPickerState) {
63e41f4b71Sopenharmony_ci    if (state == AVCastPickerState.STATE_APPEARING) {
64e41f4b71Sopenharmony_ci      console.log('The picker starts showing.');
65e41f4b71Sopenharmony_ci    } else if (state == AVCastPickerState.STATE_DISAPPEARING) {
66e41f4b71Sopenharmony_ci      console.log('The picker finishes presenting.');
67e41f4b71Sopenharmony_ci    }
68e41f4b71Sopenharmony_ci  }
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci  @Builder
71e41f4b71Sopenharmony_ci  customPickerBuilder(): void {
72e41f4b71Sopenharmony_ci    Image(this.pickerImage)
73e41f4b71Sopenharmony_ci      .width('100%')
74e41f4b71Sopenharmony_ci      .height('100%')
75e41f4b71Sopenharmony_ci      .fillColor(Color.Black)
76e41f4b71Sopenharmony_ci  }
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci  build() {
79e41f4b71Sopenharmony_ci    Row() {
80e41f4b71Sopenharmony_ci      Column() {
81e41f4b71Sopenharmony_ci        AVCastPicker({
82e41f4b71Sopenharmony_ci          normalColor: Color.Red,
83e41f4b71Sopenharmony_ci          customPicker: () => this.customPickerBuilder(),
84e41f4b71Sopenharmony_ci          onStateChange: this.onStateChange
85e41f4b71Sopenharmony_ci        })
86e41f4b71Sopenharmony_ci          .width('40vp')
87e41f4b71Sopenharmony_ci          .height('40vp')
88e41f4b71Sopenharmony_ci          .border({ width: 1, color: Color.Red })
89e41f4b71Sopenharmony_ci      }.height('50%')
90e41f4b71Sopenharmony_ci    }.width('50%')
91e41f4b71Sopenharmony_ci  }
92e41f4b71Sopenharmony_ci}
93e41f4b71Sopenharmony_ci```
94