创建 live-player 上下文 LivePlayerContext 对象
参数
| 属性 | 类型 | 默认值 | 必填 | 说明 | 
| id | string |  | 是 | live-player 组件的 id | 
实例的方法
void LivePlayerContext.play(Object object)
播放
参数
| 属性 | 类型 | 默认值 | 必填 | 说明 | 
| success | function |  | 否 | 接口调用成功的回调函数 | 
| fail | function |  | 否 | 接口调用失败的回调函数 | 
| complete | function |  | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 
void LivePlayerContext.stop(Object object)
停止
参数
同LivePlayerContext.play参数
void LivePlayerContext.mute(Object object)
静音
参数
同LivePlayerContext.play参数
void LivePlayerContext.pause(Object object)
暂停
参数
同LivePlayerContext.play参数
void LivePlayerContext.resume(Object object)
恢复
参数
同LivePlayerContext.play参数
注意:
1.此接口用于从停止状态恢复播放状态,暂停时调用不生效
void LivePlayerContext.snapshot(Object object)
截图
参数
同LivePlayerContext.play参数
示例代码
WXML
| <live-player id="player" src="https://domain/pull_stream" /><button bindtap="bindPlay" type="primary">播放</button>
 <button bindtap="bindPause" type="primary">暂停</button>
 <button bindtap="bindStop" type="primary">停止</button>
 <button bindtap="bindResume" type="primary">恢复</button>
 <button bindtap="bindMute" type="primary">静音</button>
 
 | 
JS
| Page({onReady: function() {
 this.context = wx.createLivePlayerContext('player');
 },
 bindPlay: function() {
 this.context.play({
 success: res => {
 console.log('play success', res)
 },
 fail: res => {
 console.log('play fail', res)
 }
 });
 },
 bindPause: function() {
 this.context.pause({
 success: res => {
 console.log('pause success', res)
 },
 fail: res => {
 console.log('pause fail', res)
 }
 });
 },
 bindStop: function() {
 this.context.stop({
 success: res => {
 console.log('stop success', res)
 },
 fail: res => {
 console.log('stop fail', res)
 }
 });
 },
 bindResume: function() {
 this.context.resume({
 success: res => {
 console.log('resume success', res)
 },
 fail: res => {
 console.log('resume fail', res)
 }
 });
 },
 bindMute: function() {
 this.context.mute({
 success: res => {
 console.log('mute success', res)
 },
 fail: res => {
 console.log('mute fail', res)
 }
 });
 }
 })
 
 | 
注释:
1.使用此接口,需要在平台打包时,在gmu文件夹下集成liveplayer.gmu