【发布时间】:2020-10-07 23:57:47
【问题描述】:
我正在尝试让特定尺寸的视频面板正常工作,但我很难让它在 Chrome 以外的浏览器中正常工作。我的堆栈是 Angular 5、Twilio Video(1.10.0 使用 npm i twilio-video)和 Twilio 库 1.13(来自这里://media.twiliocdn.com/taskrouter/js/v1.13/taskrouter.min.js)
我有以下代码(基于 QuickStart 项目:https://github.com/twilio/video-quickstart-js),它在 Chrome 中运行良好,并为我提供了一个 195 宽的窗口,但是当我在 Firefox 中运行相同的代码时,我得到了一个视频640x480 的窗口。在这里的任何帮助将不胜感激!
import { connect, Room, Track } from 'twilio-video';
makeConnection(token: string, roomName: string): void {
connect(token,
{
audio: true,
name: roomName,
video: { width: 195 }
}
).then(room => {
this.room = room;
this.roomJoined(room);
}, error => {
this.error = error;
});
}
roomJoined(room) {
// Attach LocalParticipant's Tracks, if not already attached.
let previewContainer = document.getElementById('local-media');
if (!previewContainer.querySelector('video')) {
console.log("Adding preview");
this.attachParticipantTracks(room.localParticipant, previewContainer);
}
// Attach the Tracks of the Room's Participants.
room.participants.forEach(participant => {
console.log("Already in Room: '" + participant.identity + "'");
let viewContainer = document.getElementById('remote-media');
this.attachParticipantTracks(participant, viewContainer);
});
// When a Participant joins the Room, log the event.
room.on('participantConnected', participant => {
console.log("Joining: '" + participant.identity + "'");
});
// When a Participant adds a Track, attach it to the DOM.
room.on('trackAdded', (track, participant) => {
console.log(participant.identity + " added track: " + track.kind);
let viewContainer = document.getElementById('remote-media');
this.attachTracks([track], viewContainer);
});
// When a Participant removes a Track, detach it from the DOM.
room.on('trackRemoved', (track, participant) => {
console.log(participant.identity + " removed track: " + track.kind);
this.detachTracks([track]);
});
// When a Participant leaves the Room, detach its Tracks.
room.on('participantDisconnected', (participant) => {
console.log("Participant '" + participant.identity + "' left the room");
this.detachParticipantTracks(participant);
});
// Once the LocalParticipant leaves the room, detach the Tracks
// of all Participants, including that of the LocalParticipant.
room.on('disconnected', () => {
console.log('Left');
if (this.previewTracks) {
this.previewTracks.forEach( (track) => {
track.stop();
});
}
room.participants.forEach(participant => this.detachParticipantTracks(participant));
});
}
// Attach the Tracks to the DOM.
attachTracks(tracks, container) {
tracks.forEach(track => {
container.appendChild(track.attach());
});
}
// Attach the Participant's Tracks to the DOM.
attachParticipantTracks(participant, container) {
let tracks = Array.from(participant.tracks.values());
this.attachTracks(tracks, container);
}
// Detach the Tracks from the DOM.
detachTracks(tracks) {
tracks.forEach(track => {
track.detach().forEach( (detachedElement) => {
detachedElement.remove();
});
});
}
// Detach the Participant's Tracks from the DOM.
detachParticipantTracks(participant) {
let tracks = Array.from(participant.tracks.values());
this.detachTracks(tracks);
}
disconnectFromRoom(): void {
console.log("Disconnecting");
this.room.disconnect();
}
【问题讨论】: