1、获取远程用户成功,然后订阅远程用户音频和视频
async function subscribe(user, mediaType) {
const uid = user.uid;
// subscribe to a remote user
await client.subscribe(user, mediaType);
console.log("subscribe success");
if (mediaType === "video") {
if ($(`#player-${uid}`).length) {
return
}
const player = $(`
uid: ${uid}
`);
$("#remote-playerlist").append(player);
user.videoTrack.play(`player - ${ uid }`);
}
if (mediaType === "audio") {
user.audioTrack.play();
}
}
2、html代码
id为local-player的div
id为remote-playerlist的div
我是参考官方的demo,第一个生成本地视频流正常,第二个div生成远程视频流时,只有声音但没有图像,本人小白,还请各位指点