阅读(766)
赞(8)
百度智能小程序 LivePlayerContext
2020-08-13 16:08:30 更新
LivePlayerContext
解释: swan.createLivePlayerContext 的返回值
属性说明
示例
图片示例
代码示例<view class="wrap">
<live-player id="myLive" src="{{src}}"></live-player>
<button type="primary" bind:tap="livePlay">播放</button>
<button type="primary" bind:tap="livePause">暂停</button>
<button type="primary" bind:tap="liveMute">点击静音</button>
<button type="primary" bind:tap="liveResume">恢复</button>
<button type="primary" bind:tap="liveStop">停止</button>
<button type="primary" bind:tap="requestFullScreen">进入全屏</button>
</view>
Page({
data: {
src: 'https://b.bdstatic.com/miniapp/development_tool/Smartprogram.mp4'
},
onReady(e) {
this.livePlayerContext = swan.createLivePlayerContext('myLive');
console.log('这是一个LivePlayerContext实例:', this.livePlayerContext);
// 使用此API需要小程序主体开通直播鉴权
},
livePlay(e) {
this.livePlayerContext.play();
},
livePause(e) {
this.livePlayerContext.pause();
},
liveStop(e) {
this.livePlayerContext.stop();
},
liveMute(e) {
this.livePlayerContext.mute();
},
liveResume(e) {
this.livePlayerContext.resume();
},
requestFullScreen(e) {
this.livePlayerContext.requestFullScreen();
}
});
Page({
data: {
src: 'https://b.bdstatic.com/miniapp/development_tool/Smartprogram.mp4'
},
onReady(e) {
this.livePlayerContext = swan.createLivePlayerContext('myLive');
console.log('这是一个LivePlayerContext实例:', this.livePlayerContext);
// 使用此API需要小程序主体开通直播鉴权
},
livePlay(e) {
this.livePlayerContext.play();
},
livePause(e) {
this.livePlayerContext.pause();
},
liveStop(e) {
this.livePlayerContext.stop();
},
liveMute(e) {
this.livePlayerContext.mute();
},
liveResume(e) {
this.livePlayerContext.resume();
},
requestFullScreen(e) {
this.livePlayerContext.requestFullScreen();
}
});
错误码
Android
错误码 | 说明 |
---|---|
201 |
解析失败,请检查调起协议是否合法 |
401 |
安全校验失败 |
1001 |
执行失败 |
iOS
错误码 | 说明 |
---|---|
202 |
解析失败,请检查参数是否正确 |
401 |
安全校验失败 |