更新记录
1.0.2(2026-07-19)
- 优化
1.0.1(2026-07-19)
- 预览:直播、截图抓图、声音开关
- 对讲:对讲、对讲音频音量大小
- 回放:回放、倍数回放、进度拖拽
1.0.0(2026-07-18)
- 直播
查看更多
平台兼容性
uni-app(3.8.0)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| √ |
√ |
- |
- |
√ |
√ |
5.0 |
√ |
- |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| - |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(3.7.11)
| Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
| - |
- |
5.0 |
√ |
- |
- |
其他
萤石SDK
- 预览:直播、截图抓图、声音开关
- 对讲:对讲、对讲音频音量大小
- 回放:回放、倍数回放、进度拖拽
集成步骤
- 拷贝demo示例项目里的AndroidManifest.xml文件到项目根目录
- 咨询或定制请点击上面"进入交流群"按钮私聊作者
- 登陆萤石管理后台创建应用获取到appKey、token
文档
import {
EZOpen
} from "@/uni_modules/wrs-uts-ezopen"
EZOpen.showSDKLog(true)
EZOpen.setDebugStreamEnable(true)
EZOpen.enableP2P(true)
let appkey = "c57dc550f94949309688a0339e017a76" // 替换成自己应用的appKey
let token = "at.b0r22z0q7wygyn850n6jt7bpa4upjuw8-7ehh4856ub-1wowp2n-eifnhjgv1" // 替换成自己应用的token
let apiUrl = "https://open.ys7.com" // 国内固定这个
let authUrl = "https://openauth.ys7.com" // 国内固定这个
let isEnableSDKWithTKToken = false
if (token.startsWith("tk.")) {
isEnableSDKWithTKToken = true
}
EZOpen.enableSDKWithTKToken(isEnableSDKWithTKToken)
let params = {}
params.appKey = appkey
params.apiUrl = apiUrl
params.authUrl = authUrl
if (isEnableSDKWithTKToken) {
params.httpToken = token
} else {
params.accessToken = token
}
EZOpen.sdkInit(params)
let params = {}
params.deviceSerial = ""
params.cameraNo = 0
EZOpen.captureCamera(params, (resp) => {
console.log("captureCamera resp:" + JSON.stringify(resp))
let result = resp.result
if (result) {
// result是抓图的地址
this.imageSrc = result
}
})
组件
<!-- #ifdef APP-HARMONY -->
<embed :style="'width:'+width+'px;height:'+height+'px;'" tag="vlc" :options="options"
@onevent="onEvent"></embed>
<!-- #endif -->
<!-- #ifndef APP-HARMONY -->
<wrs-uts-ezopenplayer ref='vlc' :params="params" :style="'width:'+width+'px;height:'+height+'px;'"
@onEvent="onEvent"></wrs-uts-ezopenplayer>
<!-- #endif -->
- 使用了该组件的页面需要用nvue或uvue
- 属性params是json格式的字符串
let deviceSerial = ""
let cameraNo = 0
let params = {}
params.businessArray = [{
business: "setUrl", // 业务
params: { // 业务参数
deviceSerial: deviceSerial,
cameraNo: cameraNo,
autoPlay: true
}
}]
let paramsStr = JSON.stringify(params)
let width = windowWidth
let height = width / (16.0 / 9.0)
return {
params: paramsStr,
options: {
params: paramsStr
},
deviceSerial: deviceSerial,
cameraNo: cameraNo,
width: width,
height: height,
imageSrc: null,
msg: null
}
onEvent(event) {
const detail = event.detail
console.log("onEvent detail:" + JSON.stringify(detail))
let opt = detail.opt
// console.log("onEvent detail:" + JSON.stringify(detail))
switch (opt) {
case "snapshot": {
// 截图回调
let filePath = detail.filePath
if (filePath) {
let path = detail.filePath
this.imageSrc = "file://" + path
} else {
this.showMsg("截图失败:" + JSON.stringify(detail))
}
}
break;
// 对讲音频音量大小
case "setVoiceTalkLoudnessCallback": {
let v = detail.v
}
break;
}
}
params.businessArray数组里支持的业务对象有:
{
business: "setUrl", // 业务
params: {
deviceSerial: "xxx", // 设备码
cameraNo: 1, // 相机编码
autoPlay: true // 是否自动播放
}
}
或者
{
business: "setUrl", // 业务
params: {
url: "rtsp://xxxx", // 直播地址
autoPlay: true // 是否自动播放
}
}
{
business: "setSound",
params: {
isOpen: true
}
}
let name = new Date().getTime()
let path = EZOpen.getFilesDir() + "/" + name + ".jpg"
{
business: "snapshot", // 截图
params: {
path: path // 本地保存图片的绝对地址
}
}
{
business: "startVoiceTalk", // 对讲
params: {
isOpen: false // 关闭
}
}
{
business: "setVoiceTalkStatus", // 对讲
params: {
isOpen: false // 关闭
}
}
business: "setVoiceTalkLoudnessCallback",
params: {
interval: 0.15
}
}
回放云端存储视频
{
business: "setUrl", // 业务
params: {
deviceSerial: "xxx", // 设备码
cameraNo: 1, // 相机编码
cloudFileKey: "" // 从EZOpen.searchRecordFileFromCloud接口获取
}
}
或
回放设备存储视频
{
business: "setUrl", // 业务
params: {
deviceSerial: "xxx", // 设备码
cameraNo: 1, // 相机编码
deviceFileKey: "" // 从EZOpen.searchRecordFileFromDevice接口获取
}
}
{
business: "setPlaybackRate", // 对讲
params: {
rate: "2" // 云端回放支持:"1/16", "1/8", "1/4", "1/2", "1", "2", "4", "8", "16", "32" 设备回放需要各自去根据设备获取
}
}
{
business: "seekPlayback", // 对讲
params: {
time: 21212121 // 播放时间戳,Android精确到毫秒,iOS精确到秒
}
}
let params = {}
params.deviceSerial = ""
params.cameraNo = 0
params.startTime = 5444 // 开始时间戳,精确到秒
params.endTime = 555 // 结束时间戳,精确到秒
// console.log("searchRecordFileFromCloud params:" + JSON.stringify(params))
EZOpen.searchRecordFileFromCloud(params, (resp) => {
let data = resp.data
if (data) {
let titles = []
let count = data.length
for (var i = 0; i < count; i++) {
let model = data[i]
let title = model.startTime + "-" + model.stopTime
titles.push(title)
}
this.showActionSheet(titles, (index) => {
let model = data[index]
this.model = model
let fileKey = model.fileKey
let newParams = {}
newParams.businessArray = [{
business: "setUrl", // 对讲
params: {
deviceSerial: this.deviceSerial,
cameraNo: this.cameraNo,
cloudFileKey: fileKey
}
}]
let newParamsStr = this.formatNewParams(newParams)
// android、ios
this.params = newParamsStr
// 鸿蒙
this.options = {
params: newParamsStr
}
})
} else {
console.log(JSON.stringify(resp))
}
})
let params = {}
params.deviceSerial = this.deviceSerial
params.cameraNo = this.cameraNo
params.startTime = startTime // 开始时间戳,精确到秒
params.endTime = endTime // 结束时间戳,精确到秒
EZOpen.searchRecordFileFromDevice(params, (resp) => {
let data = resp.data
if (data) {
let titles = []
let count = data.length
for (var i = 0; i < count; i++) {
let model = data[i]
let title = model.startTime + "-" + model.stopTime
titles.push(title)
}
this.showActionSheet(titles, (index) => {
let model = data[index]
this.model = model
let fileKey = model.fileKey
let newParams = {}
newParams.businessArray = [{
business: "setUrl",
params: {
deviceSerial: this.deviceSerial,
cameraNo: this.cameraNo,
deviceFileKey: fileKey
}
}]
let newParamsStr = this.formatNewParams(newParams)
// android、ios
this.params = newParamsStr
// 鸿蒙
this.options = {
params: newParamsStr
}
})
} else {
console.log(JSON.stringify(resp))
}
})