uniapp直播项目学习笔记4-推流功能

1.使用live-pusher 创建推流组件,具体配置如下,详细说明可查看https://uniapp.dcloud.io/api/media/live-pusher-context?id=createlivepushercontext

<live-pusher
		id='livePusher'
		ref="livePusher" 
		class="livePusher" 
		:url="url"
		:mode="mode" 
		:enable-camera="enableCamera" 
		:auto-focus="true" 
		:device-position="position"
		:beauty="beauty" 
		:whiteness="whiteness"
		aspect="9:16" 
		@statechange="statechange" 
		@netstatus="netstatus" 
		@error = "error"
		:style="'height: '+windowHeight+'px;'"
		style="width: 750rpx;"></live-pusher>

2.使用uni.createLivePusherContext(livePusherId, this) 创建 live-pusher 上下文 livePusherContext 对象。将其拿到然后实现预览预览等功能。

具体说明:https://uniapp.dcloud.io/api/media/live-pusher-context?id=createlivepushercontext

		onLoad() {
			let res = uni.getSystemInfoSync()
			this.windowHeight = res.windowHeight
		},
		onReady() {
			this.context = uni.createLivePusherContext('livePusher', this)
			this.startPreview()
		},
		methods: {
			// 开启预览
			startPreview(){
				this.context.startPreview({
					success:(e)=>{
						console.log(e);
					}
				})
			},

3.实现具体功能

以美颜为例,在点击时将其对于的popup的dialog组件的type名称传递过去,并赋值到data中,这样就知道具体点击了哪个功能,从而用v-if控制对应dailog的显示隐藏

<view style="height: 120rpx;width: 100rpx;"
 class="flex flex-column align-center justify-center" 
@click="openPopup('beauty')"







<!-- 美颜 -->
<view v-else-if="popupType === 'beauty'">
		<slider :min="0" :max="9" :step="1" :value="beauty" :block-size="18" show-value @change="handleSliderChange"/>
</view>
<!-- 美白 -->
<view v-else>
	<slider :min="0" :max="9" :step="1" :value="whiteness" :block-size="18" show-value @change="handleSliderChange"/>
</view>

美颜功能可用slider组件进行实现

具体配置:https://uniapp.dcloud.io/component/slider

  弹出框的具体标题显示可用计算属性拿到data中的数据后进行返回再动态绑定到组件上

		computed: {
			popupTitle() {
				let o = {
					mode:"画质",
					beauty:"美颜",
					whiteness:"美白",
				}
				return o[this.popupType]
			}

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值