# LivePusherContext

> 相关文档: [live-pusher 组件](/miniprogram/dev/component/live-pusher.md)

LivePusherContext 实例，可通过 [wx.createLivePusherContext](/miniprogram/dev/api/media/live/wx.createLivePusherContext) 获取。

[LivePusherContext](/miniprogram/dev/api/media/live/LivePusherContext) 与页面内唯一的 [live-pusher](/miniprogram/dev/component/live-pusher.md) 组件绑定，操作对应的 [live-pusher](/miniprogram/dev/component/live-pusher.md) 组件。

## 方法

### [LivePusherContext.start()](/miniprogram/dev/api/media/live/LivePusherContext.start)

开始推流，同时开启摄像头预览

### [LivePusherContext.stop()](/miniprogram/dev/api/media/live/LivePusherContext.stop)

停止推流，同时停止摄像头预览

### [LivePusherContext.pause()](/miniprogram/dev/api/media/live/LivePusherContext.pause)

暂停推流

### [LivePusherContext.resume()](/miniprogram/dev/api/media/live/LivePusherContext.resume)

恢复推流

### [LivePusherContext.switchCamera()](/miniprogram/dev/api/media/live/LivePusherContext.switchCamera)

切换前后摄像头

### [LivePusherContext.snapshot(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.snapshot)

快照

### [LivePusherContext.toggleTorch()](/miniprogram/dev/api/media/live/LivePusherContext.toggleTorch)

切换手电筒

### [LivePusherContext.playBGM(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.playBGM)

播放背景音

### [LivePusherContext.stopBGM()](/miniprogram/dev/api/media/live/LivePusherContext.stopBGM)

停止背景音

### [LivePusherContext.pauseBGM()](/miniprogram/dev/api/media/live/LivePusherContext.pauseBGM)

暂停背景音

### [LivePusherContext.resumeBGM()](/miniprogram/dev/api/media/live/LivePusherContext.resumeBGM)

恢复背景音

### [LivePusherContext.setBGMVolume(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.setBGMVolume)

设置背景音音量

### [LivePusherContext.setMICVolume(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.setMICVolume)

设置麦克风音量

### [LivePusherContext.startPreview()](/miniprogram/dev/api/media/live/LivePusherContext.startPreview)

开启摄像头预览

### [LivePusherContext.stopPreview()](/miniprogram/dev/api/media/live/LivePusherContext.stopPreview)

关闭摄像头预览

### [LivePusherContext.sendMessage(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.sendMessage)

发送SEI消息

### [LivePusherContext.exitPictureInPicture()](/miniprogram/dev/api/media/live/LivePusherContext.exitPictureInPicture)

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

### [LivePusherContext.setZoom(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.setZoom)

设置缩放级别

### [LivePusherContext.getMaxZoom()](/miniprogram/dev/api/media/live/LivePusherContext.getMaxZoom)

获取最大缩放级别

### [LivePusherContext.applyFilter(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.applyFilter)

添加滤镜效果

### [LivePusherContext.clearFilters()](/miniprogram/dev/api/media/live/LivePusherContext.clearFilters)

清除所有滤镜效果

### [LivePusherContext.applySticker(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.applySticker)

添加贴纸特效

### [LivePusherContext.clearStickers()](/miniprogram/dev/api/media/live/LivePusherContext.clearStickers)

清除所有贴纸特效

### [LivePusherContext.applyLipStickMakeup(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.applyLipStickMakeup)

添加口红美妆特效

### [LivePusherContext.applyEyeShadowMakeup(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.applyEyeShadowMakeup)

添加眼影美妆特效

### [LivePusherContext.applyBlusherStickMakeup(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.applyBlusherStickMakeup)

添加腮红美妆特效

### [LivePusherContext.applyFaceContourMakeup(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.applyFaceContourMakeup)

添加修容美妆特效

### [LivePusherContext.applyEyeBrowMakeup(Object object)](/miniprogram/dev/api/media/live/LivePusherContext.applyEyeBrowMakeup)

添加眉毛美妆特效

### [LivePusherContext.clearMakeups()](/miniprogram/dev/api/media/live/LivePusherContext.clearMakeups)

清除所有美妆特效

### [LivePusherContext.onCustomRendererEvent(string event, LivePusherContext.customRendererFrameEventCallback|LivePusherContext.customRendererUpdateEventCallback callback)](/miniprogram/dev/api/media/live/LivePusherContext.onCustomRendererEvent)

开启自定义渲染时，开发者通过此方法订阅相关事件，客户端 8.0.31 版本开始支持。

### [LivePusherContext.createOffscreenCanvas(object options)](/miniprogram/dev/api/media/live/LivePusherContext.createOffscreenCanvas)

创建一个能够承接 LivePusher 采集纹理的离屏 Canvas，客户端 8.0.31 版本开始支持。

## 示例代码

[在开发者工具中预览效果](https://developers.weixin.qq.com/s/KvWD9mmA62Yk)
