search
HomeWeb Front-enduni-appHow to implement live broadcast bypass push in uniapp (step sharing)

How to implement live broadcast bypass push in uniapp? The following article will summarize and share with you the steps for bypass push. I hope it will be helpful to you!

How to implement live broadcast bypass push in uniapp (step sharing)

Basically implement uniapp video calls through anyRTC audio and video SDK plug-in If basic video calls are not implemented, please refer to the article (https://blog.csdn.net/anyRTC/article/details/121352746)

Bypass push steps

1. Activate the corresponding permissions

Go to anyRTC Console - Usage Statistics Select the corresponding item to enable the bypass push service

How to implement live broadcast bypass push in uniapp (step sharing)

2. Mode adjustment

  • Scene adjustmentsdk default communication Scenario, the communication mode needs to be converted to live broadcast mode

     // 设置直播模式
     rtcModule.setChannelProfile({
        "profile": 1
     }, (res) => {
         console.log(res);
     }
  • Role adjustmentRole-Anchor: Can publish and receive audio and video streams Role - Audience: Can only receive audio and video streams

    // 1 设置为主播 2 设置为观众
    rtcModule.setClientRole({
     "role": 1
    }, (res) => {
    	console.log(res);
    })

3. Set push view layout and audio settings

  • Download the anyRTC audio and video SDK plug-in example from the uniapp plug-in market

  • Introduce LiveTranscoding## in utils/classes.js #, TranscodingUser

    import { LiveTranscoding, TranscodingUser } from "./classes.js"

    LiveTranscoding: The encapsulated general layout TranscodingUser: The encapsulated anchor layout

  • Set the view layout and audio settings of the push stream

    When the channel continues to add anchors and merges the push streams, just call the settings again

  • // 单个主播布局
    // const anchor = new TranscodingUser(主播标识uid, {
    //				width: 280,
    //				height: 210,
    //				x: 0,
    //				y: 0
    // })
    // 多个主播布局(3列)
    let anchorList= [];
    lists.map((item,index)=> {
       anchorList.push(new TranscodingUser(主播标识uid, {
    				width: 280,
    				height: 210,
    				x: (index % 3) * 280,
    				y: Math.floor(index / 3) * 210,
    	}))
    }
    // 设置旁路推流(3列)
     rtcModule.setLiveTranscoding({
    			"transcoding": new LiveTranscoding(anchorList, {
    				width: 840,
    				height: Math.ceil(anchorList.length / 3) * 210,
    			})
    }, (ret) => {
    		console.log(ret);
    });

4. Push flow

Please traverse the push flow when you need to push multiple streams

rtcModule.addPublishStreamUrl({
			url: 推流的cdn地址,
			transcodingEnabled: true // 转码是指在旁路推流时对音视频流做一些转码处理后再推送到其他 RTMP 服务器
		}, (res) => {
			console.log("添加旁路推流", res);
		});

Determine the streaming status through the onRtmpStreamingStateChanged callback Add the callback to setCallBack, and pass the relevant status code below:

        // 状态码
		state: {
			0: "推流未开始或已结束",
			1: "正在连接 AR 推流服务器和 RTMP 服务器",
			2: "推流正在进行,成功推流后",
			3: "正在恢复推流",
			4: "推流失败"
		},
		// 错误码
		errorCode: {
			0: "推流成功",
			1: "参数无效,请检查输入参数是否正确。请确保调用 setLiveTranscoding ",
			2: "推流已加密,不能推流",
			3: "推流超时未成功,可重新推流",
			4: "推流服务器出现错误",
			5: "RTMP 服务器出现错误",
			6: "推流请求过于频繁",
			7: "单个主播的推流地址数目达到上线 10",
			8: "主播操作不属于自己的流,请检查 App 逻辑",
			9: "服务器未找到这个流",
			10: "推流地址格式有错误,请检查推流地址格式是否正确",
		}

5. Stop pushing

rtcModule.removePublishStreamUrl({
			url: 推流的cdn地址,
		}, (res) => {
			console.log("取消旁路推流", res);
		});

Recommendation: "

uniapp tutorial"

The above is the detailed content of How to implement live broadcast bypass push in uniapp (step sharing). For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:掘金社区. If there is any infringement, please contact admin@php.cn delete
如何在uniapp中实现图片预览功能如何在uniapp中实现图片预览功能Jul 04, 2023 am 10:36 AM

如何在uni-app中实现图片预览功能引言:在移动应用开发中,图片预览是一项常用的功能。在uni-app中,我们可以通过使用uni-ui插件或自定义组件来实现图片预览功能。本文将介绍如何在uni-app中实现图片预览功能,并附带代码示例。一、使用uni-ui插件实现图片预览功能uni-ui是由DCloud开发的一套基于Vue.js的组件库,提供了丰富的UI组

如何在uniapp中实现相机拍照功能如何在uniapp中实现相机拍照功能Jul 04, 2023 am 09:40 AM

如何在uniapp中实现相机拍照功能现在的手机功能越来越强大,几乎每个手机都配备了高像素的相机。在UniApp中实现相机拍照功能,可以为你的应用程序增添更多的交互性和丰富性。本文将针对UniApp,介绍如何使用uni-app插件来实现相机拍照功能,并提供代码示例供参考。一、安装uni-app插件首先,我们需要安装一个uni-app的插件,该插件可以方便地在u

手把手教你uniapp和小程序分包(图文)手把手教你uniapp和小程序分包(图文)Jul 22, 2022 pm 04:55 PM

本篇文章给大家带来了关于uniapp跨域的相关知识,其中介绍了uniapp和小程序分包的相关问题,每个使用分包小程序必定含有一个主包。所谓的主包,即放置默认启动页面/TabBar 页面,以及一些所有分包都需用到公共资源/JS 脚本;而分包则是根据开发者的配置进行划分,希望对大家有帮助。

uniapp中如何使用地理位置获取功能uniapp中如何使用地理位置获取功能Jul 04, 2023 am 08:58 AM

uniapp是一种基于Vue.js的跨平台开发框架,它可以同时开发微信小程序、App和H5页面。在uniapp中,我们可以通过使用uni-api来访问设备的各种功能,包括地理位置获取功能。本文将介绍在uniapp中如何使用地理位置获取功能,并附上代码示例。首先,在uniapp中使用地理位置获取功能,我们需要在manifest.json文件中申请权限。在man

uniapp中如何使用视频播放器组件uniapp中如何使用视频播放器组件Jul 04, 2023 am 10:13 AM

uniapp中如何使用视频播放器组件随着移动互联网的发展,视频已成为人们日常生活中不可或缺的娱乐方式之一。在uniapp中,我们可以通过使用视频播放器组件来实现视频的播放和控制。本文将介绍如何在uniapp中使用视频播放器组件,并提供相应的代码示例。一、引入视频播放器组件在uniapp中,我们需要先引入视频播放器组件才能使用它的功能。可以通过在页面的json

如何在uniapp中实现图片滤镜效果如何在uniapp中实现图片滤镜效果Jul 04, 2023 am 11:05 AM

如何在uniapp中实现图片滤镜效果在移动应用开发中,图片滤镜效果是一种常见且受用户喜爱的功能之一。而在uniapp中,实现图片滤镜效果也并不复杂。本文将为大家介绍如何通过uniapp实现图片滤镜效果,并附上相关代码示例。导入图片首先,我们需要在uniapp项目中导入一张图片,以供后续滤镜效果的处理。可以在项目的资源文件夹中放置一张命名为“filter.jp

UniApp实现性能监控与瓶颈分析的最佳实践UniApp实现性能监控与瓶颈分析的最佳实践Jul 04, 2023 am 08:46 AM

UniApp实现性能监控与瓶颈分析的最佳实践随着移动应用的快速发展,开发人员对应用性能的需求也日益增加。对于UniApp开发者来说,实现性能监控和瓶颈分析是非常重要的一项工作。本文将介绍UniApp中实现性能监控和瓶颈分析的最佳实践,并提供一些代码示例供参考。一、性能监控的重要性在现代移动应用中,用户体验是非常重要的。性能问题会导致应用加载速度慢、卡顿等问题

UniApp实现启动图与引导图的配置与使用指南UniApp实现启动图与引导图的配置与使用指南Jul 04, 2023 am 11:09 AM

UniApp实现启动图与引导图的配置与使用指南引言:UniApp是一个基于Vue.js开发的跨平台应用开发框架,可通过一套代码实现同时在iOS、Android、H5等多个平台下运行。在移动应用的开发中,启动图与引导图是提升用户体验的关键因素之一。本文将详细介绍UniApp中如何配置和使用启动图与引导图,并附上相应的代码示例。一、配置启动图在UniApp的项目

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools