目录

PlayerClient

Class Info

public class PlayerClient

Cast Engine大屏设备侧实例。

Public Method Summary

Qualifier and Type

Method Name and Description

PlayerClient

getInstance()()

获取PlayerClient实例。

boolean

init(Context context)

初始化投屏服务。

void

deinit()()

注销投屏服务。

boolean

registerCallback(IEventListener listener)

注册手机连接状态与大屏投屏业务的回调。

void

unregisterCallback(IEventListener listener)

注销手机连接状态与大屏投屏业务的回调。

boolean

setAuthMode(AuthInfo info)

设置当前设备鉴权模式。

boolean

setDiscoverable(boolean enable, DeviceInfo info)

设置当前大屏端设备是否可被发现。

boolean

setCapability(HiSightCapability capability)

设置大屏端设备支持的投屏能力。

boolean

play(ProjectionDevice device)

启动投屏。

boolean

play(TrackControl tc)

启动投屏。

boolean

pause(ProjectionDevice device)

@Deprecated

暂停投屏。(该方法已废弃,可用pause(TrackControl tc)代替)

boolean

pause(TrackControl tc)

暂停投屏。

boolean

setHiSightSurface(Surface surface)

设置显示投屏画面的Surface。首次投屏或Surface发生变更时必须重新设置,并调用play()方法开始投屏。

void

disconnectDevice(ProjectionDevice device)

断开连接。

boolean

setConnectRequestChooseResult(ConnectRequestChoice choice)

未连接过设备连接到大屏端时,会通过Constant.EVENT_ID_PIN_CODE_SHOW事件通知应用层显示对应的提示框,请大屏端用户确认是否可以允许远端设备投屏,选择结果通过该方法设置。

boolean

setDisplayInfo(DisplayInfo displayInfo)

当大屏端旋转或者图像尺寸发生变化时,重新设置显示相关信息。

Public Methods

[h2]getInstance()

Method

public static PlayerClient getInstance()

获取PlayerClient实例。

Return

Type

Description

PlayerClient

PlayerClient实例。

[h2]init(Context context)

Method

public boolean init(Context context)

初始化投屏服务。

Parameters

Name

Description

context

PlayerClient依赖的上下文。

Return

Type

Description

boolean

  • True:初始化已启动
  • False:初始化异常

[h2]deinit()

Method

public void deinit()

注销投屏服务。

[h2]registerCallback(IEventListener listener)

Method

public boolean registerCallback (IEventListener listener)

注册手机连接状态与大屏投屏业务的回调。

Parameters

Name

Description

listener

事件接收接口。

Return

Type

Description

boolean

  • True:注册成功
  • False:注册失败

[h2]unregisterCallback(IEventListener listener)

Method

public void unregisterCallback (IEventListener listener)

注销手机连接状态与大屏投屏业务的回调。

Parameters

Name

Description

listener

事件接收接口。

[h2]setAuthMode(AuthInfo info)

Method

public boolean setAuthMode(AuthInfo info)

设置当前设备鉴权模式。

Parameters

Name

Description

info

设备鉴权模式,可选值有:

AuthInfo.AUTH_MODE_GENERIC:PIN码模式

AuthInfo.AUTH_MODE_PWD:密码模式

Return

Type

Description

boolean

  • True:设置成功
  • False:设置失败

[h2]setDiscoverable(boolean enable, DeviceInfo info)

Method

public boolean setDiscoverable(boolean enable, DeviceInfo info)

设置当前大屏端设备是否可被发现。

Parameters

Name

Description

enable

  • True:大屏端设备可被发现
  • False:大屏端设备不可被发现

info

本地设备信息对象。

Return

Type

Description

boolean

  • True:设置成功
  • False:设置失败

[h2]setCapability(HiSightCapability capability)

Method

public boolean setCapability(HiSightCapability capability)

设置大屏端设备支持的投屏能力。

Parameters

Description

Description

capability

端侧设备能力。

Return

Type

Description

boolean

  • True:设置成功
  • False:设置失败

[h2]play(ProjectionDevice device)

Method

public boolean play(ProjectionDevice device) @Deprecated

启动投屏。(该方法已废弃,可用play(TrackControl tc)代替)

Parameters

Name

Description

device

要投屏的对端的设备。

Return

Type

Description

boolean

  • True:启动投屏成功
  • False:启动投屏失败

[h2]play(TrackControl tc)

Method

public boolean play(TrackControl tc)

启动投屏。

Parameters

Name

Description

tc

音视频轨控制信息。

Return

Type

Description

boolean

  • True:启动投屏成功
  • False:启动投屏失败

[h2]pause(ProjectionDevice device)

Method

public boolean pause(ProjectionDevice device) @Deprecated

暂停投屏。(该方法已废弃,可用pause(TrackControl tc)代替)

Parameters

Name

Description

device

要投屏的对端的设备。

Return

Type

Description

boolean

  • True:启动暂停流程
  • False:未发起暂停

[h2]pause(TrackControl tc)

Method

public boolean pause(TrackControl tc)

暂停投屏。

Parameters

Name

Description

tc

音视频轨控制信息。

Return

Type

Description

boolean

  • True:启动暂停流程
  • False:未发起暂停

[h2]setHiSightSurface(Surface surface)

Method

public boolean setHiSightSurface(Surface surface)

设置显示投屏画面的Surface。首次投屏或Surface发生变更时必须重新设置,并调用play()方法开始投屏。

Parameters

Name

Description

surface

用于显示投屏内容的Surface。

Return

Type

Description

boolean

  • True:设置成功
  • False:设置失败

[h2]disconnectDevice(ProjectionDevice device)

Method

public void disconnectDevice (ProjectionDevice device)

断开连接。

Parameters

Name

Description

device

要断开的对端设备。

[h2]setConnectRequestChooseResult(ConnectRequestChoice choice)

Method

public boolean setConnectRequestChooseResult(ConnectRequestChoice choice)

未连接过设备连接到大屏端时,会通过Constant.EVENT_ID_PIN_CODE_SHOW事件通知应用层显示对应的提示框,请大屏端用户确认是否可以允许远端设备投屏,选择结果通过该方法设置。

Parameters

Name

Description

choice

连接请求确认结果类,可选值有:

Return

Type

Description

boolean

  • True:设置成功
  • False:底层未处理

[h2]setDisplayInfo(DisplayInfo displayInfo)

Method

public boolean setDisplayInfo (DisplayInfo displayInfo)

当大屏端旋转或者图像尺寸发生变化时,重新设置图像尺寸,旋转方向等信息。

Parameters

Name

Description

displayInfo

可以设置图像尺寸,旋转方向,是否为悬浮窗等信息,具体请参考DisplayInfo。

Return

Type

Description

boolean

  • True:设置成功
  • False:设置失败