提交工单
咨询集成、功能及报价等问题
在开始集成 ZEGO Express SDK 前,请确保开发环境满足以下要求:
浏览器的兼容性请参考 ZEGO Express Web SDK 支持哪些浏览器。
开发者可通过以下任意一种方式集成 SDK。
下载最新版本的 SDK 并解压。
解压 SDK 压缩包,我们可以在 “dist_js/” 下找到 “ZegoExpressWebRTC-x.x.x.js” 文件。
新建 “index.html” 文件,并放置于和 “ZegoExpressWebRTC-x.x.x.js” 相同的目录下,编写好界面代码,并在 “index.html” 文件的 head 中引入 “ZegoExpressWebRTC-x.x.x.js”。其中,“x.x.x” 为 SDK 的版本号,请参考上一步压缩包解压后的文件名修改。
“index.html” 代码示例如下:
<html>
<head>
<meta charset="UTF-8">
<title>Zego Express Video Call</title>
<style type="text/css">
* {
font-family: sans-serif;
}
h1,
h4 {
text-align: center;
}
#local-video, #remote-video {
width: 400px;
height: 300px;
border: 1px solid #dfdfdf;
}
#local-video {
position: relative;
margin: 0 auto;
display: block;
}
#remote-video {
display: flex;
margin: auto;
position: relative !important;
}
</style>
</head>
<body>
<h1>
Zego RTC Video Call
</h1>
<h4>Local video</h4>
<div id="local-video"></div>
<h4>Remote video</h4>
<div id="remote-video"></div>
<script> // 教程中的 js 代码可粘贴至此 <script> 标签内
// const zg = new ZegoExpressEngine(appID, server);
</script>
</body>
</html>
├── index.html
├── index.js
<html>
<head>
<meta charset="UTF-8">
<title>Zego Express Video Call</title>
<style type="text/css">
* {
font-family: sans-serif;
}
h1,
h4 {
text-align: center;
}
#local-video, #remote-video {
width: 400px;
height: 300px;
border: 1px solid #dfdfdf;
}
#local-video {
position: relative;
margin: 0 auto;
display: block;
}
#remote-video {
display: flex;
margin: auto;
position: relative !important;
}
</style>
</head>
<body>
<h1>
Zego RTC Video Call
</h1>
<h4>Local video</h4>
<div id="local-video"></div>
<h4>Remote video</h4>
<div id="remote-video"></div>
<script src="index.js"></script>
</body>
</html>
在终端中,cd 到 ”index.js“ 文件所在的文件夹,执行 npm i zego-express-engine-webrtc
命令安装依赖。
sudo
重新执行即可。import {ZegoExpressEngine} from 'zego-express-engine-webrtc'
或
var ZegoExpressEngine = require('zego-express-engine-webrtc').ZegoExpressEngine
本地服务器(localhost 或 127.0.0.1)运行 Web 应用仅作为测试,生产环境必须使用 https 协议。
1. 在命令行中执行 `npm i live-server -g` 命令,安装 live-server。
2. 进入项目所在的根目录。
3. 执行 `live-server .` 命令运行该项目,浏览器会自动打开 “index.html” 页面。
联系我们
文档反馈