admin管理员组文章数量:1417582
I set up a basic code in client-side to receive producer info from server-side and create tag with that.
try {
const { id, producerId, kind, rtpParameters } = consumerInfo[key];
const codecOptions = {};
const consumer = await consumerTransportRef.current.consume({
id,
producerId,
kind,
rtpParameters,
codecOptions,
});
const stream = new MediaStream();
stream.addTrack(consumer.track);
createMediaElement(kind, stream, user_id);
} catch (error) {
console.error(mediasoupErrorMessage.unknow, error);
}
}
The createMediaElement funtion
function createMediaElement(kind, stream, userId) {
let mediaElement;
const container = document.getElementById(cameraPlaceholder);
if (!container) {
console.error(`Container element '${cameraPlaceholder}' not found!`);
return;
}
if (kind === "audio") {
mediaElement = document.createElement("audio");
mediaElement.id = `remoteAudio_${userId}`;
mediaElement.srcObject = stream;
mediaElement.autoplay = true;
mediaElement.controls = false;
mediaElement.style.display = "none";
} else if (kind === "video") {
console.log("Video tracks:", stream.getVideoTracks());
mediaElement = document.createElement("video");
mediaElement.id = `remoteVideo_${userId}`;
mediaElement.srcObject = stream;
mediaElement.autoplay = true;
mediaElement.playsInline = true;
mediaElement.muted = true;
mediaElement.style.width = "340px";
mediaElement.style.height = "180px";
}
container.appendChild(mediaElement);
}
The problem is it always return me a black box, even when the kind, stream, userId is not null.
I did try to log the stream, stream.active = true
, id exists. Is there any things that I miss in here.
本文标签: nodejsGet black box in ltvideogt when using webRTC mediasoupStack Overflow
版权声明:本文标题:node.js - Get black box in <video> when using webRTC mediasoup - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745273597a2651045.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论