Skip to content

Commit 4fe0c0d

Browse files
authored
Merge pull request #279 from Ezviz-OpenBiz/develop
update
2 parents a3cc9dd + 6492726 commit 4fe0c0d

File tree

18 files changed

+132
-89
lines changed

18 files changed

+132
-89
lines changed

README.md

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
### 获取 ezuikit-js
1919

20-
```
20+
```bash
21+
# npm
2122
npm install ezuikit-js
2223

2324
# yarn
@@ -31,13 +32,13 @@ pnpm add ezuikit-js
3132

3233
### 引入 ezuikit-js
3334

34-
```
35+
```js
3536
import EZUIKit from 'ezuikit-js';
3637
```
3738

3839
#### 如果你使用原生方法,可以通过标签引用
3940

40-
```
41+
```html
4142
<!-- umd -->
4243
<script src="./ezuikit.js"></script>
4344
```
@@ -48,7 +49,7 @@ import EZUIKit from 'ezuikit-js';
4849
4950
创建 DOM
5051

51-
```
52+
```html
5253
<div id="video-container"></div>
5354
```
5455

@@ -57,7 +58,7 @@ import EZUIKit from 'ezuikit-js';
5758
### 直播
5859

5960
```js
60-
var player = new EZUIKit.EZUIKitPlayer({
61+
const player = new EZUIKit.EZUIKitPlayer({
6162
id: "video-container", // 视频容器ID
6263
accessToken:
6364
"at.3bvmj4ycamlgdwgw1ig1jruma0wpohl6-48zifyb39c-13t5am6-yukyi86mz",
@@ -75,7 +76,7 @@ var player = new EZUIKit.EZUIKitPlayer({
7576
### 回放
7677

7778
```js
78-
var player = new EZUIKit.EZUIKitPlayer({
79+
const player = new EZUIKit.EZUIKitPlayer({
7980
id: "video-container", // 视频容器ID
8081
width: 600,
8182
height: 400,
@@ -119,7 +120,7 @@ alpha(功能测试)、beta(集成测试)为我们的非正式版本,
119120
> 轻应用支持向接入萤石云海外环境的设备发起取流播放,需要在初始化时配置海外服务域名,示例:
120121
121122
```js
122-
EZOPENDemo = new EZUIKit.EZUIKitPlayer({
123+
const player = new EZUIKit.EZUIKitPlayer({
123124
id: "playWind",
124125
width: 600,
125126
height: 400,
@@ -473,46 +474,46 @@ player.stopTalk();
473474

474475
#### 对讲设置麦克风增益
475476

476-
```
477-
// 设置音频增益系数 0 ~ 10
478-
player.setVolumeGain(volume);
477+
```js
478+
// 设置音频增益系数 0 ~ 10
479+
player.setVolumeGain(volume);
479480
```
480481

481482
#### 获取麦克风权限
482483

483-
```
484-
player.getMicrophonePermission().then(data => {
485-
if (data.code === 0) {
486-
// 成功....
487-
}
488-
})
484+
```js
485+
player.getMicrophonePermission().then(data => {
486+
if (data.code === 0) {
487+
// 成功....
488+
}
489+
})
489490
```
490491

491492
#### 获取麦克风列表
492493

493-
```
494-
// 需要在麦克风已授权的情况下调用,才能获取到麦克风列表,可以和getMicrophonePermission配合使用,或在初始化后先调用getMicrophonePermission获取授权
495-
player.getMicrophonesList().then(data => {
496-
if (data.code === 0) {
497-
// 成功....
498-
}
499-
})
494+
```js
495+
// 需要在麦克风已授权的情况下调用,才能获取到麦克风列表,可以和getMicrophonePermission配合使用,或在初始化后先调用getMicrophonePermission获取授权
496+
player.getMicrophonesList().then(data => {
497+
if (data.code === 0) {
498+
// 成功....
499+
}
500+
})
500501
```
501502

502503
#### 切换麦克风
503504

504-
```
505-
// microphoneId 为获取到的麦克风列表中的deviceId,如果当前处于对讲中,调用setProfile会先关闭,重新发起对讲
506-
player.setProfile({ microphoneId })
505+
```js
506+
// microphoneId 为获取到的麦克风列表中的deviceId,如果当前处于对讲中,调用setProfile会先关闭,重新发起对讲
507+
player.setProfile({ microphoneId })
507508
```
508509

509510
#### 监听麦克风音量变化
510511

511-
```
512-
player.eventEmitter.on('volumeChange', ({ data }) => {
513-
// 动态显示音柱,100ms触发一次
514-
console.log(`${data * 100}%`)
515-
})
512+
```js
513+
player.eventEmitter.on('volumeChange', ({ data }) => {
514+
// 动态显示音柱,100ms触发一次
515+
console.log(`${data * 100}%`)
516+
})
516517
```
517518

518519
#### 全屏
@@ -555,7 +556,6 @@ options 参数说明
555556
| accessToken | String | N | 初始化时获取 | 授权过程获取的 access_token |
556557
| hd | boolean | N | 初始化时获取 | 是否为高清 true-主码流(高清) false-子码流(标清) |
557558
| validCode | String | N | 初始化时获取 | 设备验证码(加密设备播放需要输入验证码) |
558-
| validCode | String | N | 初始化时获取 | 设备验证码(加密设备播放需要输入验证码) |
559559
| begin | String | N | 初始化时获取 | type 类型为回放有效,开始时间 格式为“YYYYMMDDHHmmss” |
560560
| end | String | N | 初始化时获取 | type 类型为回放有效,结束时间 格式为 “YYYYMMDDHHmmss” |
561561

@@ -564,14 +564,13 @@ options 参数说明
564564
> 可用于在播放中切换模板主题,请切换播放地址成功后调用
565565
566566
```js
567-
player.Theme.changeTheme(template)
568-
569-
// 预览切回放场景示例
570-
player.changePlayUrl({type:"rec"});
571-
.then(()=>{
572-
console.log("地址切换成功,开始切换模板主题");
573-
player.Theme.changeTheme("pcRec");
574-
});
567+
player.Theme.changeTheme(template)
568+
569+
// 预览切回放场景示例
570+
player.changePlayUrl({type:"rec"}).then(()=>{
571+
console.log("地址切换成功,开始切换模板主题");
572+
player.Theme.changeTheme("pcRec");
573+
});
575574
```
576575

577576
template 参数说明

demos/base-demo/ezuikit.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demos/base-demo/index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
77
<title>Document</title>
8+
<style>
9+
#video-container {
10+
width: 600px;
11+
height: 400px;
12+
background-color: #000;
13+
}
14+
</style>
815
<script src="./ezuikit.js"></script>
916
</head>
1017

@@ -46,8 +53,8 @@ <h2>视频模式使用示例:</h2>
4653
player = new EZUIKit.EZUIKitPlayer({
4754
id: "video-container", // 视频容器ID
4855
accessToken:
49-
"at.5eust80k24rnxeao5ubhg3we8xg3fe2y-2obk7hy2h9-0c9z5t2-6gjyxouc",
50-
url: "ezopen://open.ys7.com/L16120197/1.hd.live",
56+
"at.1gskp9sk9b8pol288qw4f0ladj6ow00a-2obk8zrvgd-0icd73x",
57+
url: "ezopen://open.ys7.com/BA7248908/1.hd.live",
5158
template: "pcLive", // simple: 极简版; pcLive: 预览; pcRec: 回放; security: 安防版; voice: 语音版;
5259
plugin: ["talk"], // 加载插件,talk-对讲
5360
width: 600,

demos/base-demo/mobileLive.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ <h2>视频模式使用示例:</h2>
3232
<button onClick="ezopenStartTalk()">开始对讲</button>
3333
<button onClick="ezopenStopTalk()">结束对讲</button>
3434
<button onClick="fullScreen()">全屏</button>
35+
<button onClick="destroy()">destroy</button>
3536
</div>
3637
<p style="font-style: italic;">播放多个视频,可初始化多个实例,参考:/demos/base-demo/multi-demo</p>
3738
</div>
@@ -46,8 +47,8 @@ <h2>视频模式使用示例:</h2>
4647
player = new EZUIKit.EZUIKitPlayer({
4748
id: 'video-container', // 视频容器ID
4849
accessToken:
49-
"at.5eust80k24rnxeao5ubhg3we8xg3fe2y-2obk7hy2h9-0c9z5t2-6gjyxouc",
50-
url: "ezopen://open.ys7.com/L16120197/1.hd.live",
50+
"at.1gskp9sk9b8pol288qw4f0ladj6ow00a-2obk8zrvgd-0icd73x-",
51+
url: "ezopen://open.ys7.com/BA7248908/1.hd.live",
5152
template: 'mobileLive', // simple: 极简版; pcLive: 预览; pcRec: 回放; security: 安防版; voice: 语音版;
5253
plugin: ['talk'], // 加载插件,talk-对讲
5354
width: width,
@@ -122,6 +123,13 @@ <h2>视频模式使用示例:</h2>
122123
function ezopenStopTalk() {
123124
player.stopTalk();
124125
}
126+
127+
function destroy() {
128+
if (player) {
129+
player.destroy();
130+
}
131+
player = null;
132+
}
125133
</script>
126134
</body>
127135

demos/base-demo/mobileRec.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
<button onClick="ezopenStartTalk()">开始对讲</button>
3131
<button onClick="ezopenStopTalk()">结束对讲</button>
3232
<button onClick="fullScreen()">全屏</button>
33+
<button onClick="destroy()">destroy</button>
34+
3335
</div>
3436
<p style="font-style: italic;">播放多个视频,可初始化多个实例,参考:/demos/base-demo/multi-demo</p>
3537
</div>
@@ -47,8 +49,8 @@
4749
player = new EZUIKit.EZUIKitPlayer({
4850
id: 'video-container', // 视频容器ID
4951
accessToken:
50-
"at.5eust80k24rnxeao5ubhg3we8xg3fe2y-2obk7hy2h9-0c9z5t2-6gjyxouc",
51-
url: "ezopen://open.ys7.com/L16120197/1.rec",
52+
"at.1gskp9sk9b8pol288qw4f0ladj6ow00a-2obk8zrvgd-0icd73x-",
53+
url: "ezopen://open.ys7.com/BA7248908/1.rec",
5254
template: 'mobileRec', // simple: 极简版; pcLive: 预览; pcRec: 回放; security: 安防版; voice: 语音版;
5355
width: width,
5456
height: width * 9 / 16,
@@ -116,12 +118,21 @@
116118
console.log("promise 获取 数据", data)
117119
})
118120
}
121+
119122
function ezopenStartTalk() {
120123
player.startTalk();
121124
}
125+
122126
function ezopenStopTalk() {
123127
player.stopTalk();
124128
}
129+
130+
function destroy() {
131+
if (player) {
132+
player.destroy();
133+
}
134+
player = null;
135+
}
125136
</script>
126137
</body>
127138

demos/nginx-demo/html/ezuikit.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demos/react-demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"ezuikit-js": "^8.1.1",
6+
"ezuikit-js": "^8.1.2-alpha.1",
77
"react": "^17",
88
"react-dom": "^17",
99
"react-scripts": "5.0.1",

demos/react-demo/pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demos/react-demo/src/Player.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import { isMobile } from "./utils";
55
const Player = () => {
66
const player = useRef();
77

8+
/** @type {React.MutableRefObject<HTMLInputElement>} */
9+
const urlRef = useRef();
10+
/** @type {React.MutableRefObject<HTMLInputElement>} */
11+
const accessTokenRef = useRef();
12+
813
const initPlayer = useCallback(() => {
914
if (document.getElementById("player-container")) {
1015
let width = 600;
@@ -22,9 +27,8 @@ const Player = () => {
2227

2328
player.current = new EZUIKit.EZUIKitPlayer({
2429
id: "player-container",
25-
url: "ezopen://open.ys7.com/BB9480953/1.hd.live",
26-
accessToken:
27-
"at.2ec3m7dga2v59cps6rv0d1haa2vqsjka-1lbu5f5hyi-1j9rleq-npvuluse",
30+
url: urlRef.current.value, // "ezopen://open.ys7.com/BB9480953/1.hd.live",
31+
accessToken: accessTokenRef.current.value, // "at.2ec3m7dga2v59cps6rv0d1haa2vqsjka-1lbu5f5hyi-1j9rleq-npvuluse",
2832
width,
2933
height,
3034
template: "pcLive",
@@ -96,7 +100,7 @@ const Player = () => {
96100
/** 获取OSD时间 */
97101
const handleGetOSDTime = useCallback(() => {
98102
if (player.current) {
99-
player.current.getOSDTime();
103+
console.log("OSDTime", player.current.getOSDTime());
100104
}
101105
}, []);
102106

@@ -130,7 +134,14 @@ const Player = () => {
130134
<h2>视频模式使用示例:</h2>
131135
<div id="player-container"></div>
132136
<div>
133-
<button onClick={initPlayer}>初始化</button>
137+
url: <input type="text" ref={urlRef} style={{ width: 500 }} />
138+
</div>
139+
<div>
140+
accessToken:
141+
<input type="text" ref={accessTokenRef} style={{ width: 500 }} />
142+
</div>
143+
<div>
144+
<button onClick={initPlayer}>init</button>
134145
<button onClick={handleStop}>stop</button>
135146
<button onClick={handlePlay}>play</button>
136147
<button onClick={handleOpenSound}>openSound</button>
@@ -140,8 +151,8 @@ const Player = () => {
140151
<button onClick={handleCapturePicture}>capturePicture</button>
141152
<button onClick={handleFullscreen}>fullScreen</button>
142153
<button onClick={handleGetOSDTime}>getOSDTime</button>
143-
<button onClick={handleStartTalk}>开始对讲</button>
144-
<button onClick={handleStopTalk}>结束对讲</button>
154+
<button onClick={handleStartTalk}>startTalk</button>
155+
<button onClick={handleStopTalk}>stopTalk</button>
145156
<button onClick={handleDestroy}>destroy</button>
146157
</div>
147158
</div>

demos/react-demo/src/index.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ code {
1111
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
1212
monospace;
1313
}
14+
15+
16+
#player-container {
17+
width: 600px;
18+
height: 400px;
19+
background-color: #000;
20+
}

0 commit comments

Comments
 (0)