[+] 视频添加

This commit is contained in:
acgist
2023-02-26 16:44:30 +08:00
parent a0ebe8c842
commit 71ada0a8ca
10 changed files with 437 additions and 86 deletions

View File

@@ -1,14 +1,88 @@
<!-- 远程终端 -->
<template>
<video></video>
<audio></audio>
<div>
<el-button type="primary" title="关闭麦克风" :icon="Edit" circle />
<div class="client">
<audio ref="audio"></audio>
<video ref="video"></video>
<div class="buttons">
<el-button type="danger" title="打开麦克风" :icon="Mute" circle />
<el-button type="primary" title="关闭麦克风" :icon="Microphone" circle />
<el-button type="danger" title="打开摄像头" :icon="VideoPause" circle />
<el-button type="primary" title="关闭摄像头" :icon="VideoPlay" circle />
<el-button title="拍照" :icon="Camera" circle />
<el-button title="录像" :icon="VideoCamera" circle />
<el-button title="媒体信息" :icon="InfoFilled" circle />
<el-button title="踢出" :icon="CircleClose" circle />
</div>
</div>
</template>
<script>
import {
Mute,
Camera,
Refresh,
VideoPlay,
VideoPause,
InfoFilled,
Microphone,
VideoCamera,
CircleClose,
} from "@element-plus/icons";
export default {
name: "RemoteClient",
}
</script>
setup() {
return {
Mute,
Camera,
Refresh,
VideoPlay,
VideoPause,
InfoFilled,
Microphone,
VideoCamera,
CircleClose,
};
},
data() {
return {
taoyao: null,
audio: null,
video: null,
audioStream: null,
videoStream: null,
dataConsumer: null,
audioConsumer: null,
videoConsumer: null,
};
},
mounted() {
this.audio = this.$refs.audio;
this.video = this.$refs.video;
},
methods: {
media(track, consumer) {
if(track.kind === 'audio') {
if (this.audioStream) {
// TODO资源释放
} else {
this.audioStream = new MediaStream();
this.audioStream.addTrack(track);
this.audio.srcObject = this.audioStream;
}
this.audio.play().catch((error) => console.warn("视频播放失败", error));
} else if(track.kind === 'video') {
if (this.videoStream) {
// TODO资源释放
} else {
this.videoStream = new MediaStream();
this.videoStream.addTrack(track);
this.video.srcObject = this.videoStream;
}
this.video.play().catch((error) => console.warn("视频播放失败", error));
} else {
}
}
}
};
</script>