track.attach を使用してリモート参加者トラックをアタッチし、track.detach() を使用してトラックを削除しようとすると、この問題に直面していますが、e.attach is not function のようなエラーが発生します このエラーを解決する方法. attachtrack 関数で、トラックをアタッチしようとすると、この問題に直面しています。私の twilio-video バージョンは 2.4.0 です。よろしくお願いします。
room.on('participantConnected', participant => {
console.log(`Participant connected: ${participant.identity}`);
// this.setTimer();
room.participants.forEach(participant => {
console.log(`Participant "${participant.identity}" is connected to the Room`);
this.participantConnected(participant, room, true);
console.log("publish--->>>", participant);
});
});
participantConnected =(participant, room, flag) =>{
participant.tracks.forEach(publication => {
this.trackPublished(publication, participant, flag);
});
// Handle theTrackPublications that will be published by the Participant later.
participant.on('trackPublished', publication => {
this.trackPublished(publication, participant, flag);
});
}
trackPublished=(publication, participant, flag)=> {
// If the TrackPublication is already subscribed to, then attach the Track to the DOM.
if (publication.track) {
this.attachTrack(publication.track, participant, flag);
}
// Once the TrackPublication is subscribed to, attach the Track to the DOM.
publication.on('subscribed', track => {
this.attachTrack(track, participant, flag);
});
// Once the TrackPublication is unsubscribed from, detach the Track from the DOM.
publication.on('unsubscribed', track => {
this.detachTrack(track, participant, flag);
});
}
attachTrack=(track, participant, flag)=>{
var mediaContainer = document.getElementById('local-media');
if (flag == true) {
if (track.kind === 'video') {
const participantdiv = document.createElement('div');
participantdiv.id = participant.sid;
remoteparticipantsid = participant.sid
console.log("add remote--->>>", participant.sid);
participantdiv.appendChild(track.attach())
mediaContainer.appendChild(participantdiv);
}
}
}