我无法显示远程参与者视频。 我收到无法读取未定义的属性“值” 因为没有参与者,所以请提出建议。
function roomJoined(room) {
console.log(room);
window.room = activeRoom = room;
var previewContainer = angular.element('#local-media');
attachParticipantTracks(room.localParticipant, previewContainer[0]);
room.on('participantConnected', function(participant) {
participant.tracks.forEach(function(participant) {
//log("Already in Room: '" + participant.identity + "'");
var previewContainerPat = angular.element('#remote-media');
console.log(previewContainerPat);
attachParticipantTracks(participant, previewContainerPat[0]);
});
room.on('trackAdded', function(track, participant) {
//log(participant.identity + " added track: " + track.kind);
var previewContainer = angular.element('#remote-media');
attachTracks([track], previewContainer[0]);
});
});
room.on('trackRemoved', function(track, participant) {
//log(participant.identity + " removed track: " + track.kind);
detachTracks([track]);
});
room.on('participantDisconnected', function(participant) {
//log("Participant '" + participant.identity + "' left the room");
// detachParticipantTracks(participant);
});
room.on('disconnected', function() {
if (previewTracks) {
previewTracks.forEach(function(track) {
track.stop();
});
previewTracks = null;
}
room.participants.forEach(detachParticipantTracks);
activeRoom = null;
});
}
function attachTracks(tracks, container) {
tracks.forEach(function(track) {
container.appendChild(track.attach());
});
}
function attachParticipantTracks(participant, container, isLocal) {
var tracks = getTracks(participant);
attachTracks(tracks, container, isLocal);
}
function getTracks(participant) {
return Array.from(participant.tracks.values()).filter(function (publication) {
return publication.track;
}).map(function (publication) {
return publication.track;
});
}`
预期结果:应该为远程参与者显示视频
实际结果:抛出错误:-无法读取未定义的属性“值” 因为没有参与者。曲目