
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
npm install webrtclib
import videoWebrtc from "webrtclib";
import "webrtclib/lib/videoWebrtc.css"
Vue.use(videoWebrtc);
<video-webrtc
:server="server"
:stun="stun"
:sid="sid"
:orgId="orgId"
@saveVideo="saveVideo"
@capture="capture"
></video-webrtc>
参数 | 类型 | 类型 | 解释 |
---|---|---|---|
server | 必传 | String | 服务地址 |
stun | 必传 | String | ice协议服务地址 |
sid | 必传 | [Number, String] | 直播时候传入的设备id |
orgId | 必传 | [Number, String] | 直播时候传入的组织ID |
custTime | 非必传 | [Number, String] | 录像时间(秒),默认5分钟,最大1小时 |
saveVideo | 非必传 | 回调方法 | 返回录像地址url |
capture | 非必传 | 回调方法 | 返回截图文件base64 |
录像需要配置proxy
proxy: {
"/webrtcApi": {
target: "http://ip:port", // 目标接口域名
pathRewrite: {
"^/webrtcApi": ""
},
changeOrigin: true // 是否跨域
}
}
<template>
<div class="home">
<div class="video" v-for="item in arr" :key="item">
<video-webrtc
:server="server"
:stun="stun"
:sid="sid"
:orgId="orgId"
@saveVideo="saveVideo"
@capture="capture"
></video-webrtc>
</div>
<div class="dialog-mask" v-if="imgCapture" @click="imgCapture = null"></div>
<div class="dilog" v-if="imgCapture">
<img v-if="imgCapture" :src="imgCapture" alt="" />
</div>
</div>
</template>
<script>
export default {
name: "Home",
data() {
return {
arr: [1, 2, 3, 4, 5, 6, 7, 8, 9],
stun: "stun://ip:port",
server: "ws://ip:port/wsrtc",
sid: "摄像头ID",
orgId: "组织ID"
imgCapture: ""
};
},
methods: {
// 截图
capture(val) {
console.log(val);
this.imgCapture = val;
},
// 录像
saveVideo(val) {
console.log(val);
}
}
};
</script>
<style>
.home {
display: flex;
flex-wrap: wrap;
}
.video {
width: 320px;
height: 180px;
position: relative;
margin: 10px;
}
.dialog-mask {
position: absolute;
z-index: 1001;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: #00000090;
}
.dilog {
position: absolute;
z-index: 1001;
width: 80%;
left: 10%;
top: 10%;
padding: 20px;
background-color: #fff;
}
</style>
FAQs
a webrtc lib for vue
We found that webrtclib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.