Web SDK 如何同时用两个视图播放同一个视频流?

  1. 播放两次本地视频流:
// 假设已有 localStream
localStream2 = AgoraRTC.createStream({
 	streamID: uid,

 	audio: false,
 	cameraId: camera,
 	microphoneId: microphone,

 	video: true,
 	screen: false
 });

 localStream2.init(function () {
 	var newVideoTrack = localStream2.getVideoTrack();
 	localStream.replaceTrack(newVideoTrack);
 	localStream2.play('agora_local1');

});
  1. 播放两次远端视频流:
<div id="video" style="margin:0 auto;">
		<div id="agora_local" style="float:right;width:300px;height:300px;display:inline-block;transform: rotateY(360deg);"></div>
		<div id="screenVideo" style="float:left;width:800px;height:600px;display:inline-block;"></div>
		<div id="agora_local1" style="float:right;width:300px;height:300px;display:inline-block;transform: rotateY(360deg);"></div>
		<div id="play1" style="float:right;width:300px;height:300px;display:inline-block;"></div>
</div>
var stream = evt.stream;
console.log("Subscribe remote stream successfully: " + stream.getId());

if($('div#video #agora_remote' + stream.getId()).length === 0) {
   $('div#video').append('<div id="agora_remote' + stream.getId() +
        ' " style="float:left; width:800px; height:500px; display:inline-block;"></div>');
}

stream.play('agora_remote' + stream.getId());

var video = document.createElement('video');
var test1 = document.getElementById('play1');
test1.appendChild(video);

video.srcObject = evt.stream.stream;

video.play();