类:CastContext

构造函数

CastContext

新的 CastContext()

方法

getInstance

静态

getInstance() 返回 cast.framework.CastContext

返回 CastContext 单例实例。

返回

cast.framework.CastContext CastContext 的单例实例。

addEventListener

addEventListener(类型, 处理程序)

添加事件侦听器。

参数

类型

cast.framework.CastContextEventType

事件类型。

值不能为 null。

handler

(非 null 函数(非 null cast.framework.CastStateEventData)或非 null 函数(非 null cast.framework.SessionStateEventData

endCurrentSession

endCurrentSession(stopCasting)

结束当前会话。

参数

停止投放

布尔值

接收器应用是停止还是刚刚断开连接。

getCastState

getCastState() 返回 cast.framework.CastState

返回

non-null cast.framework.CastState:当前的投放图标状态。

getCurrentSession

getCurrentSession() 会返回 cast.framework.CastSession

返回

nullable cast.framework.CastSession 当前会话。

getSessionState

getSessionState() 会返回 cast.framework.SessionState

返回

non-null cast.framework.SessionState:当前会话状态。

移除事件监听器

removeEventListener(类型, 处理程序)

移除事件监听器。

参数

类型

cast.framework.CastContextEventType

事件类型。

值不能为 null。

handler

(非 null 函数(非 null cast.framework.CastStateEventData)或非 null 函数(非 null cast.framework.SessionStateEventData

requestSession

requestSession() 会返回包含可为 null 的 chrome.cast.ErrorCode 的 Promise

打开投放选择界面,以便用户启动或停止会话。

抛出

Error 如果上下文选项尚未提供。

返回

non-null Promise containing nullable chrome.cast.ErrorCode 表明会话正在启动或失败的 promise(拒绝并返回错误代码)。

setLaunchCredentialsData

setLaunchCredentialsData(credentialsData)

设置用户凭据数据。如果在 setOptions 之前调用,将被忽略。在 setLaunchCredentialsData 之后调用 setOptions 将清除在 setLaunchCredentialsData 中设置的值。

参数

凭据数据

chrome.cast.CredentialsData

用于标识发送者凭据的凭据数据。

值不能为 null。

setOptions

setOptions(选项)

设置投放选项。 只有在提供配置后,系统才会发送事件。

参数

选项

cast.framework.CastOptions

网页的投放选项。

值不能为 null。

抛出

non-null Error 如果选项缺少应用 ID。