4

I have added twilio video js file from cdn "// media.twiliocdn.com/sdk/js/video/releases/1.14.1/twilio-video.min.js"

I tried to add adepter.js but seems same error.

        Twilio.Video.createLocalTracks({
            audio: true,
            video: { width: 300 }
        }).then(function(localTracks) {

            return Twilio.Video.connect('{!! $accessToken !!}', {
                name: '{{ $roomName }}',
                tracks: localTracks,
                video: { width: 300 }
            });
        }).then(function(room) {

            console.log('Successfully joined a Room: ', room.name);

            room.participants.forEach(participantConnected);

            var previewContainer = document.getElementById(room.localParticipant.sid);
            if (!previewContainer || !previewContainer.querySelector('video')) {
                participantConnected(room.localParticipant);
            }

            room.on('participantConnected', function(participant) {
                console.log("Joining: '" + participant.identity + "'");
                participantConnected(participant);
            });

            room.on('participantDisconnected', function(participant) {
                console.log(participant);
                console.log("Disconnected: '" + participant.identity + "'");
                participantDisconnected(participant,room);
            });


        });

Always got :- Call to getUserMedia failed: DOMException

  • 1
    I have the same issue, did you get any solution for this? – Sethu May 16 '19 at 17:00
  • For me it was my browser. I noticed that the camera was being blocked so when I clicked to unblock it, everything worked fine. I'll have to error handle this cause the user could also "deny" access when the popup for camera access appears. – Costa May 26 '23 at 10:17

2 Answers2

3

Not 100% sure if this applies to this scenario, but for me this happened when I tried to connect or create local video track when there was no camera available i.e. my laptop was on external monitor with the lid being closed. Once there was a proper device was available then it connected just fine.

You can access the error message in the DOMExpception object via error.message attribute. If it says "Device not available" or something similar then it probably is just that. Dunno why the whole object does not print to the console or there is no error handling build in to Twilio SDK for this, I would guess this happens quite often.

Possible pattern to tackle this issue is to check if there's any devices of required type available in navigator.mediaDevices and after that add proper initialization parameters for the .connect() call. I haven't got a hang of this yet but probably the best approach is to create tracks separately from the connection since user can change the device at any given point.

Aleksi
  • 520
  • 4
  • 10
1

The error is not due to twilio or google chrome or any other browser... I'm not sure that's exactly the case for you but for me it was that I was trying to test the video experience on two different browsers on the same computer. So the first one which accesses the resources i.e. camera & mic was able to successfully connect while the second browser threw an exception of [createLocalTracks #2] Call to getUserMedia failed: DOMException: Could not start video source

SaqiXPRO
  • 145
  • 1
  • 2
  • 8