稍后再做

This commit is contained in:
TonyChyi 2022-09-27 17:23:49 +08:00
parent de24203100
commit 24ae8d7657
2 changed files with 24 additions and 1 deletions

3
TODO Normal file
View File

@ -0,0 +1,3 @@
1. 视频分辨率切换问题
2. 还是没声音
3. 综合调试

View File

@ -2,7 +2,7 @@
<div> <div>
<canvas id="vnc" /> <canvas id="vnc" />
<div id="data"> <div id="data">
<video id="video" muted autoplay /> <video id="video" muted autoplay controls="none" />
<audio id="audio" autoplay /> <audio id="audio" autoplay />
</div> </div>
</div> </div>
@ -66,6 +66,7 @@ onMounted(() => {
props.methods.resetVM = resetVM; props.methods.resetVM = resetVM;
const video = document.querySelector("canvas#vnc"); const video = document.querySelector("canvas#vnc");
video.oncontextmenu = () => false;
store.getICEServers().then((servers) => { store.getICEServers().then((servers) => {
const pc = new RTCPeerConnection({ const pc = new RTCPeerConnection({
@ -99,6 +100,13 @@ onMounted(() => {
el.controls = false; el.controls = false;
el.oncontextmenu = () => false; el.oncontextmenu = () => false;
document.getElementById("data").appendChild(el); document.getElementById("data").appendChild(el);
if (el.track.kind === "video") {
const ctx = video.getContext("2d");
setTimeout(() => {
ctx.drawImage(this.video, 0, 0);
}, 0);
}
}; };
dataChannel.onopen = () => { dataChannel.onopen = () => {
@ -156,6 +164,7 @@ onMounted(() => {
</script> </script>
<style scoped> <style scoped>
/*
video#video { video#video {
vertical-align: middle; vertical-align: middle;
top: 50%; top: 50%;
@ -165,4 +174,15 @@ video#video {
max-height: 100%; max-height: 100%;
max-width: 100%; max-width: 100%;
} }
*/
canvas#vnc {
vertical-align: middle;
top: 50%;
transform: translateY(-50%) translateX(-50%);
left: 50%;
position: absolute;
max-height: 100%;
max-width: 100%;
}
</style> </style>