Browse Source

add video as canvas size

m7s
superxxd 2 years ago
parent
commit
0fbc06f136
  1. 15
      test/mqtt.js

15
test/mqtt.js

@ -14,6 +14,21 @@ function OnTrack(pc){
pc.ontrack = function (event) { pc.ontrack = function (event) {
console.log("ontrack", event.track.kind) console.log("ontrack", event.track.kind)
var el = document.createElement(event.track.kind); var el = document.createElement(event.track.kind);
document.body.appendChild(el);
//属性width height autoplay id type src,也可以通过userVideo.setAttribute('type','video/mp4');来设置
if(event.track.kind==="video"){
const canvasId = "playCanvas";
canvas = document.getElementById(canvasId);
var offsetY = canvas.offsetTop;
var offsetX = canvas.offsetLeft;
el.offsetTop = offsetY;
el.offsetLeft = offsetX;
el.width = canvas.width;
el.height = canvas.height;
el.autoplay = true;
el.id = 'metaRTCVideo';
}
el.srcObject = event.streams[0]; el.srcObject = event.streams[0];
el.autoplay = true; el.autoplay = true;
// document.getElementById("remote-video").appendChild(el); // document.getElementById("remote-video").appendChild(el);

Loading…
Cancel
Save