更新记录

0.1.1(2021-01-21)

支持视频直播,连麦互动 支持音频直播,连麦互动 支持白板信令传送


平台兼容性

Android Android CPU类型 iOS
适用版本区间:5.0 - 11.0 armeabi-v7a:支持,arm64-v8a:支持,x86:未测试 适用版本区间:9 - 14

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


ZegoExpressUniAppSDK

即构科技 (ZEGO) 极速音视频 uni-app SDK 是一个基于 ZegoExpressEngine 原生 Android / iOS SDK 的 uni-app Wrapper,提供视频直播以及实时音视频服务。仅需几行代码,30分钟即可轻松接入。

了解更多解决方案:https://www.zego.im

使用方法

申请 ZEGO AppID

登录 ZEGO 官网 注册账号,根据自身实际业务需求选择场景,获取 AppID 与 AppSign,用于初始化 SDK。

创建uniapp项目

使用uniapp官方IDE HBuilder,创建uni-app类型的项目

获取「ZegoExpressEngine」uniapp SDK,并引入工程

在uniaapp市场获取本插件,并将插件引入工程

下载「js封装层」代码,并引入工程

下载地址

http://zego-public.oss-cn-shanghai.aliyuncs.com/express/video/uniapp/zego-express-video-uniapp.zip

将以上「js封装层」引入到uniapp项目中

基础使用(音频)

初始化 SDK

import ZegoExpressEngine from 'zego-express-video-uniapp/ZegoExpressEngine';

import {
    ZegoScenario
} from 'zego-express-video-uniapp/impl/ZegoExpressDefines'

var instance = ZegoExpressEngine.createEngine(AppID, AppSign, false, ZegoScenario.General);

关闭视频功能

//不启用摄像头
instance.enableCamera(false);
//关闭视频流
instance.mutePublishStreamVideo(true)

注册通知事件

instance.on('roomStateUpdate', result => {
  console.log('From Native roomStateUpdate:' + result);
  if(result['state'] == 0) { //房间断开

  } else if(result['state'] == 1) { //房间连接中

  } else if(result['state'] == 2) { //房间连接成功

  }
});
instance.on('engineStateUpdate', result => {
  if(result == 0) { //'引擎启动'

  } else if(result['state'] == 1) { //'引擎停止'

  }
});
instance.on('roomStreamUpdate', result => {
  var updateType = result['updateType'];
  if (updateType === 0) { //房间内有新增流
    this.streamList = result['streamList'];
    //通常来说,当收到房间内流新增的消息时,可以立即拉流播放音频
    var instance = ZegoExpressEngine.getInstance();
    instance.startPlayingStream(this.streamList[0].streamID)
  } else if (updateType === 1) { //房间内有流被移除

  }
});

instance.on('roomUserUpdate', result => {
  var updateType = result['updateType'];
  if (updateType === 0) { //房间内有用户新增

  } else if (updateType === 1) { //房间内有用户被移除

  }
});

登录

var instance = ZegoExpressEngine.getInstance();
instance.loginRoom(this.roomID, { userID: this.userID, userName: this.userName });

推流

var instance = ZegoExpressEngine.getInstance();
var publishStreamID = '123456'
instance.startPublishingStream(publishStreamID); //推流(推流的streamID由用户设置),需要在登录成功之后才执行推流

拉流

instance.startPlayingStream(streamID); //拉流的streamID来自于事件'roomStreamUpdate'获取的stream中的streamID

基础使用(视频)

拉流

如果启用视频功能,拉流播放的时候需保证template标签内有相应的zego-view标签,该标签内需绑定相应流的streamID,此标签会在原生端生成对应的view,展示拉流的画面 使用示例:

<template>
    <zego-view :streamID="stream.streamID" style="margin-top: 0rpx;margin-left: 10rpx;width:200rpx;height:300rpx"></zego-view>
</template>

js部分:
var instance = ZegoExpressEngine.getInstance();
instance.startPlayingStream(stream.streamID);

预览

预览的时候需保证template标签内有相应的zego-preview-view标签,该标签内可绑定相应的channel(该参数非必填),channel的概念参考接口startPreview

此标签会在原生端生成对应的view,展示拉流的画面 使用示例:

<template>
    <zego-preview-view style="margin-top: 20rpx;margin-left: 20rpx;width:200rpx;height:300rpx"></zego-preview-view>
</template>

js部分:
var instance = ZegoExpressEngine.getInstance();
instance.startPreview();

特别提示:

使用视频功能时,页面必须使用.nvue文件构建,因为uniapp的.vue页面在原生端(iOS、android)是用 webview 构建的,不能支持component类型的插件

详情可参考:https://nativesupport.dcloud.net.cn/NativePlugin/course/ios

推流

var instance = ZegoExpressEngine.getInstance();
var publishStreamID = '123456'
instance.startPublishingStream(publishStreamID);

更多功能

1、参考示例源码

2、参考ZegoExpressEngine 原生iOS版使用文档 https://doc-zh.zego.im/zh/5413.html

示例源码使用

示例源码下载地址

ZegoExpressExample-UniApp

  1. 将Demo导入HBuilderX,修改manifest.json下的AppID(uniapp的AppID)
  2. 修改Demo下./KeyCenter.js 内的AppID、AppSign (从ZEGO官网获取的)
  3. 导入「ZegoExpressEngine」uniapp SDK
  4. 使用uniapp本地打包/云打包,制定自定义基座
  5. 运行

隐私、权限声明

1. 本插件需要申请的系统权限列表:

摄像头,录音

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

采集摄像头、麦克风数据 具体可参考 https://doc-zh.zego.im/zh/5416.html

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT License

Copyright (c) 2020 ZEGO

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问