ProfileBasepublic final class A2dpSink extends Object implements ProfileBase
The static method getProfile(ohos.app.Context) is used to obtain A2dpSink instances.
You can use getDevicesByStates(int[]) to obtain devices in the specified state, use
getDeviceState(ohos.bluetooth.BluetoothRemoteDevice) to obtain the status of a peer device,
and use getPlayingState(ohos.bluetooth.BluetoothRemoteDevice) to obtain the A2dpSink playing status of a device.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
STATE_NOT_PLAYING |
Indicates that the A2DP sink is not playing.
|
static int |
STATE_PLAYING |
Indicates that the A2DP sink is playing.
|
A2DP, A2DP_SINK, CONNECT_STRATEGY_ALLOW, CONNECT_STRATEGY_AUTO, CONNECT_STRATEGY_DISALLOW, CONNECT_STRATEGY_UNKNOWN, GATT, GATT_SERVER, HFP, HFP_UNIT, MAP_SERVER, PBAP_CLIENT, PBAP_SERVER, PROFILE_PARAM_CUR_STATE, PROFILE_PARAM_PRE_STATE, SOCKET_MANAGER, STATE_CONNECTED, STATE_CONNECTING, STATE_DISCONNECTED, STATE_DISCONNECTING| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
connect(BluetoothRemoteDevice device) |
Connects a remote device from the A2DP sink.
|
boolean |
disconnect(BluetoothRemoteDevice device) |
Disconnects a remote device of the A2DP sink.
|
List<BluetoothRemoteDevice> |
getDevicesByStates(int[] status) |
Obtains the list of devices in the specified status.
|
int |
getDeviceState(BluetoothRemoteDevice device) |
Obtains the connection status of a
BluetoothRemoteDevice in the current profile. |
int |
getPlayingState(BluetoothRemoteDevice device) |
Obtains the A2DP sink playing status of a peer device.
|
static A2dpSink |
getProfile(Context context) |
Obtains the default
A2dpSink instance to perform an A2DP sink operation. |
public static final int STATE_NOT_PLAYING
public static final int STATE_PLAYING
public static A2dpSink getProfile(Context context)
A2dpSink instance to perform an A2DP sink operation.context - Indicates the ability context that contains the package name.A2dpSink instance.public List<BluetoothRemoteDevice> getDevicesByStates(int[] status)
ProfileBasegetDevicesByStates 在接口中 ProfileBasestatus - Indicates the connection status, which can be ProfileBase.STATE_DISCONNECTED,
ProfileBase.STATE_CONNECTING, ProfileBase.STATE_CONNECTED, or ProfileBase.STATE_DISCONNECTING.BluetoothRemoteDevice matching the specified status.public int getDeviceState(BluetoothRemoteDevice device)
ProfileBaseBluetoothRemoteDevice in the current profile.getDeviceState 在接口中 ProfileBasedevice - Indicates the BluetoothRemoteDevice.ProfileBase.STATE_DISCONNECTED, ProfileBase.STATE_CONNECTING,
ProfileBase.STATE_CONNECTED, or ProfileBase.STATE_DISCONNECTING.public int getPlayingState(BluetoothRemoteDevice device)
device - Indicates the peer device BluetoothRemoteDevice.STATE_PLAYING
or STATE_NOT_PLAYING.public boolean connect(BluetoothRemoteDevice device)
device - Indicates the peer device BluetoothRemoteDevice.true if the connection is successful; returns false otherwise.public boolean disconnect(BluetoothRemoteDevice device)
device - Indicates the peer device BluetoothRemoteDevice.true if the disconnection is successful; returns false otherwise.