LivePlayerContext.pause

2020-08-26 16:34 更新

解释:暂停

方法参数

Object object

object参数说明

属性名类型默认值必填说明

success

Function

接口调用成功的回调函数

fail

Function

接口调用失败的回调函数

complete

Function

接口调用结束的回调函数(调用成功、失败都会执行)

示例 

在开发者工具中打开



图片示例

代码示例

<view class="wrap">
    <live-player id="myLive"  src="{{src}}"  autoplay="true">
    </live-player>
    <button type="primary" bind:tap="livePause" disabled="{{disabled}}">暂停播放 pause</button>
    <button type="primary" bind:tap="liveResume" disabled="{{!disabled}}">恢复播放 resume</button>
</view>
Page({
    data: {
        disabled: false,
        src: 'https://b.bdstatic.com/miniapp/development_tool/Smartprogram.mp4'
    },
    onReady() {
        this.livePlayerContext = swan.createLivePlayerContext('myLive');
    },
    livePause(e) {
        swan.showToast({
            title: '已暂停',
            icon: 'none'
        });
        this.livePlayerContext.pause();
        this.setData({disabled: true}) 
    },
    liveResume() {
        swan.showToast({
            title: '已恢复',
            icon: 'none'
        });
        this.livePlayerContext.resume();
        this.setData({disabled: false})
    }
});


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号