dt-record-controller
v1.0.4
Published
send command to dengta recording service to control start/stop
Downloads
15
Readme
v1.0.4
- 加入retry允许重试
v1.0.3
- 更新readme
v1.0.2
- 去掉端口特性,默认4444端口
v1.0.1
- 修复url里有#时取参数无效的bug
- 修复stopRecord的bug
v1.0.0
第一版上线
如何安装
使用如下命令安装
npm install dt-record-controller --save
如何使用
- 引入库里的三个函数,分别是初始化,开始录制命令,结束录制命令
import { initRecordController, startRecord, stopRecord, retry } from "dt-record-controller";
- 在页面执行入口处,如create,mount这里,首选执行
initRecordController()
- 在需要开始录像的地方执行
startRecord()
- 在需要结束录像的地方执行
stopRecord()
- 如果在加载阶段捕获到错误,需要重试,可以发起重试
retry()
示例代码
<template>
<div class="video_holder">
<img :src="gif" alt="" class="the_gif" />
</div>
</template>
<script>
import { initRecordController, startRecord, stopRecord } from "dt-record-controller";
export default {
data() {
return {
gif: require("./200w.webp"),
};
},
methods: {
async sleep(seconds) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, seconds);
});
},
},
async mounted() {
//初始化录制器
initRecordController();
//这里模拟的是预加载过程
//需要预加载好字体,图片,视频,数据等所有需要录制的资源,避免录制开始后才开始加载
await this.sleep(Math.random() * 10 * 1000);
//发送开始录制命令,如果超过3分钟未发送开始命令,会让录制任务失败
startRecord();
//这里模拟的是视频录制中
await this.sleep(Math.random() * 10 * 1000);
//发送结束录制命令,如果超过10分钟未发送结束命令,会让录制任务失败
stopRecord();
},
};
</script>
如何调试
页面里使用如上语句后,即可在浏览器f12的console一栏看到每个命令的执行打印。
==============initRecordController==============
==============StartRecord==============
==============StopRecording==============
如看到打印,说明代码使用无误;
如未看到,说明未按预期执行开始命令或结束命令,请自行检查逻辑!