我正在将Twilio与twilio-video
v beta-2
配合使用,依靠此repohttps://github.com/twilio/video-quickstart-js的主分支
我必须显示选择的媒体并将设备推入其中,并且该开关在ios safari浏览器上运行,但是在chrome浏览器和firefox浏览器上的android nasier上却不起作用
NotReadableError: could not start a video source
我的updateVideoDevice
函数如下所示
function updateVideoDevice(event) {
const select = event.target
const localParticipant = room.localParticipant
log('change fired ' + select.value);
if (select.value !== '') {
Video.createLocalVideoTrack({
audio: true,
video: {width: 640},
deviceId: {exact: select.value}
}).then((localVideoTrack) => {
const tracks = Array.from(localParticipant.videoTracks.values())
.map(publication => publication.track);
localParticipant.unpublishTracks(tracks)
console.log(localParticipant.identity + " removed track: " + tracks[0].kind)
tracks.forEach(track => {
track.detach().forEach(detachedElement => {
detachedElement.remove()
})
})
localParticipant.publishTrack(localVideoTrack)
console.log(localParticipant.identity + " added track: " + localVideoTrack.kind)
const previewContainer = document.getElementById('local-media');
if (!previewContainer.querySelector('video')) {
attachParticipantTracks(room.localParticipant, previewContainer)
}
// attachTracks([localVideoTrack], previewContainer)
}).catch((error) => {
log(error)
});
}
}