更新记录
0.0.3(2025-04-30) 下载此版本
更新说明文档
0.0.2(2025-04-30) 下载此版本
API 更新
0.0.1(2025-04-29) 下载此版本
首个版本,支持 Android 平台。
查看更多平台兼容性
Vue2 | Vue3 |
---|---|
× | × |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
HBuilderX 4.31,Android:5.0,iOS:不支持,HarmonyNext:不支持 | × | × | × | × | × | × |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 | 鸿蒙元服务 |
---|---|---|---|---|
× | × | × | × | × |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | × | × | × |
rapid-kit
rapid-kit
是探鸽物联网视频开放平台面向 uni-app 开发场景提供的 SDK,用于支持原生 Android / iOS 设备上快速实现 IoT 视频客户端。
"RAPID" = Real-time Audio-visual Platform for IoT Devices.
为物联网视觉设备提供一个高效的跨平台音视频解决方案。
准备工作
参考文档向平台申请接入。
API 说明
初始化 SDK
export type RapidKitOptions = {
appId: string // 申请得到的 APPID
packageName: string // 应用包名,使用探鸽账号体系时才需要填写;否则传空字符串即可
}
// 返回 true 即表示初始化成功,可以开始使用后文的功能
export type rapidKitInitialize = (options: RapidKitOptions) => boolean
用户鉴权
// 参数为平台下发的 token,返回 true 即表示鉴权成功,可以开始使用下述功能
export type rapidKitAuthenticate = (token: string) => boolean
实时音视频播放
1. 在页面中声明 rapid-kit-texture
组件
rapid-kit-texture
是一个组件,用于在视图树中展示一个原生视频窗口,并由 SDK 在运行时在其中渲染实时视频画面。
注意:你需要为每一个rapid-kit-texture
提供一个唯一的id
,这是为了让播放器可以与组件建立关联。
<template>
<view>
<!-- 其他组件 ... -->
<view>
<rapid-kit-texture id="texture_0" style="width: 100%;height: 300px;background-color: black;"></rapid-kit-texture>
</view>
</view>
</template>
2. 创建播放器实例
/// textureId 即 rapid-kit-texture 组件的 "id" 值
/// 函数返回 RapidKitLivePlayer的实例
export type rapidKitCreateLivePlayer = (deviceId : string) => RapidKitLivePlayer
3. 播放器 API
export class RapidKitLivePlayer {
// 将播放器与一个原生视频组件绑定
// 注意:必须在调用 start() 之前调用此方法
public attach(textureId : string)
// 设置渲染状态变化回调
public onRenderStateChanged(l : ((state : number) => void)) {}
// 开始播放
public start() {}
// 停止播放
public stop() {}
// 销毁播放器实例,释放底层资源
public release() {}
}
一个完整示例
你可在导入本插件之后,在index.uvue
中直接替换以下代码来体验:
<template>
<view>
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title">{{title}}</text>
<text class="status">Auth Status: {{isAuthSuccess ? 'Success' : 'Failed'}}</text>
</view>
<view class="button-group">
<button class="control-button" @click="handleCreate">Create Player</button>
<button class="control-button" @click="handleStart">Start Player</button>
<button class="control-button" @click="handleStop">Stop Player</button>
<button class="control-button" @click="handleRelease">Release Player</button>
</view>
<view>
<rapid-kit-texture id="texture_0" style="width: 100%;height: 300px;background-color: black;"></rapid-kit-texture>
</view>
</view>
</template>
<script>
import {
RapidKitOptions,
rapidKitInitialize,
rapidKitAuthenticate,
rapidKitCreateLivePlayer,
RapidKitLivePlayer
} from '@/uni_modules/rapid-kit'
export default {
data() {
return {
title: 'Hello',
isAuthSuccess: false,
playerId: 0,
player: null as RapidKitLivePlayer | null
}
},
onLoad() {
let init = rapidKitInitialize({
appId: "ad_xxxx",
packageName: "com.xxx.xxx"
})
if (!init) {
console.log("[onLoad] init failed")
return
}
let auth = rapidKitAuthenticate("eyJ....")
this.isAuthSuccess = auth
console.log("[onLoad] auth " + (auth ? "success" : "failed"))
},
methods: {
handleCreate() {
if (!this.isAuthSuccess) {
console.log("[handleCreate] not authenticated")
return
}
this.player = rapidKitCreateLivePlayer("48E36JSZN2NM")
this.player!.onRenderStateChanged((state) => {
console.log(">>>>>>> state == " + state)
})
this.player!.attach("texture_0")
},
handleStart() {
this.player!.start()
},
handleStop() {
this.player!.stop()
},
handleRelease() {
this.player!.release()
this.player = null
}
}
}
</script>
<style>
.logo {
height: 100px;
width: 100px;
margin: 100px auto 25px auto;
}
.title {
font-size: 18px;
color: #8f8f94;
text-align: center;
}
.status {
display: block;
text-align: center;
margin: 10px 0;
color: #8f8f94;
}
.button-group {
display: flex;
flex-direction: column;
gap: 10px;
margin: 20px;
}
.control-button {
margin: 0;
}
</style>