阅读(4152) (3)

百度智能小程序 创建LivePlayerContext

2020-08-13 16:08:30 更新

swan.createLivePlayerContext

解释: 操作对应的 <live-player/> 组件。 创建并返回 live-player 上下文 LivePlayerContext 对象。

方法参数

String domId

domId参数说明

要获取 live-player 组件的 id。

返回值

LivePlayerContext

示例 

在开发者工具中打开



图片示例

代码示例

<view class="wrap">
    <live-player id="myLive" src="{{src}}"></live-player>
</view>
Page({
    data: {
        src: 'https://b.bdstatic.com/miniapp/development_tool/Smartprogram.mp4'
    },
    onLoad() {
        this.livePlayerContext = swan.createLivePlayerContext('myLive');
        // 使用详看 LivePlayerContext (https://smartprogram.baidu.com/docs/develop/api/media/liveplayercontext_LivePlayerContext/)
        // 使用此API需要小程序主体开通直播鉴权
    }
});