LivePlayerContext.reconnectCasting(Object object)

从基础库 2.32.0 开始支持,低版本需做兼容处理。

以 Promise 风格调用:不支持

微信小程序插件:支持

限制:仅在点击行为时调用

相关文档: live-player 组件

功能描述

重连投屏设备。仅支持在 tap 事件回调内调用。

参数

Object object

属性 类型 默认值 必填 说明
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)

LivePlayerContext.play(Object object)

以 Promise 风格调用:不支持

微信小程序插件:支持

相关文档: live-player 组件

功能描述

播放

参数

Object object

属性 类型 默认值 必填 说明
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)

LivePlayerContext.pause(Object object)

从基础库 1.9.90 开始支持,低版本需要做兼容处理。

以 Promise 风格调用:不支持

微信小程序插件:支持

相关文档:live-player 组件

功能描述

暂停

参数

Object object

属性 类型 默认值 必填 说明
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)

LivePlayerContext.mute(Object object)

以 Promise 风格调用:不支持

微信小程序插件:支持

相关文档: live-player 组件

功能描述

静音

参数

Object object

属性 类型 默认值 必填 说明
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)

LivePlayerContext.exitPictureInPicture(Object object)

以 Promise 风格调用:不支持

微信小程序插件:支持

相关文档: live-player 组件

功能描述

退出小窗,该方法可在任意页面调用

参数

Object object

属性 类型 默认值 必填 说明
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)

LivePlayerContext.exitFullScreen(Object object)

以 Promise 风格调用:不支持

微信小程序插件:支持

相关文档: live-player 组件

功能描述

退出全屏

参数

Object object

属性 类型 默认值 必填 说明
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)

LivePlayerContext.exitCasting(Object object)

从基础库 2.32.0 开始支持,低版本需要做兼容处理。

以 Promise 风格调用:不支持

微信小程序插件:支持

限制:仅在点击行为时调用

相关文档: live-player 组件

功能描述

退出投屏。仅支持在 tap 事件回调内调用。

参数

Object object

属性 类型 默认值 必填 说明
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)

LivePlayerContext

相关文档: live-player 组件

LivePlayerContext 实例,可通过 wx.createLivePlayerContext 获取。

LivePlayerContext 通过 id 跟一个 live-player 组件绑定,操作对应的 live-player 组件。

方法

LivePlayerContext.play()

播放

LivePlayerContext.stop()

停止

LivePlayerContext.mute()

静音

LivePlayerContext.pause()

暂停

LivePlayerContext.resume()

恢复

LivePlayerContext.requestFullScreen(Object object)

进入全屏

LivePlayerContext.exitFullScreen()

退出全屏

LivePlayerContext.exitPictureInPicture()

退出小窗,该方法可在任意页面调用

LivePlayerContext.snapshot(Object object)

截图

LivePlayerContext.requestBackgroundPlayback()

进入后台小窗播放模式。

LivePlayerContext.exitBackgroundPlayback()

退出后台小窗播放模式。

LivePlayerContext.startCasting()

开始投屏,拉起半屏搜索设备。仅支持在 tap 事件回调内调用。

LivePlayerContext.switchCasting()

切换投屏设备。仅支持在 tap 事件回调内调用。

LivePlayerContext.reconnectCasting()

重连投屏设备。仅支持在 tap 事件回调内调用。

LivePlayerContext.exitCasting()

退出投屏。仅支持在 tap 事件回调内调用。

示例代码

在开发者工具中预览效果

wx.createLivePlayerContext(string id, Object this)

基础库 1.7.0 开始支持,低版本需做兼容处理。

微信小程序插件:支持,需要微信小程序基础库版本不低于 1.9.6

微信 Windows 版:支持

微信 Mac 版:支持

微信 鸿蒙 OS 版:支持

相关文档: live-player 组件

功能描述

创建 live-player 上下文 LivePlayerContext 对象。建议使用 wx.createSelectorQuery 获取 context 对象。

参数

string id

live-player 组件的 id

Object this

在自定义组件下,当前组件实例的 this,用于操作组件内的 live-player 组件

返回值

LivePlayerContext