uniapp推流

<template>
	<view>
		<live-pusher id="livePusher" :url="url" :enable-camera="enableCamera" mode="FHD"></live-pusher>
		<button @click="startLive">开始推流(开始直播)</button>
		<button @click="stopLive">结束推流</button>
	</view>
</template>
<script>
    export default {
		data() {
			return {
				url: 'rtmp://192.168.1.11:1935/live/621FD133-889D-1707-CF0E-83A8A715D412',
				enableCamera: true,
				context: null
			};
		},
		onReady() {
			this.context = uni.createLivePusherContext('livePusher', this);
			this.context.switchCamera() // 摄像头切换(切换为后置)
			this.context.startPreview() // 摄像头预览 (不加会黑屏)
		},
		methods: {
			startLive() {
				this.context.start({
					success: a => {
						console.log('livePusher.start:' + JSON.stringify(a));
					}
				});
			},
			stopLive() {
				this.context.stop({
					success: a => {
						console.log(JSON.stringify(a));
					}
				});
			}
		}
    }
</script>
<style>
    video {
        width: 690 rpx;
    }
</style>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值