javascript - Twilio Video. I can display video without sound -
i testing twillio functionality. backend(sending tokens, access rights) works fine. in frontend part video remote participant without sound. can see eachother. can't hear him , can't hear me. how repair it? have sound , have option mute/unmute sound microphone remote participant can't hear me. if have other suggestions code please let me know.
this part of html:
<div class="container" id="conversation"> <div> <video id="localvideo" ></video> <video id="patientvideo"></video> <div class="buttons"> <span> <a href="{% url 'calendar' %}?day={{ request.get.day }}"> <img class="btn" id="call" src="{% static 'images/conversation/finish-phone-call.png' %}" alt="call"/></a> </span> <span> <img class="btn" id="mute" src="{% static 'images/conversation/icon-microphone-mute-01.png' %}" alt="mute"/> <img class="btn" id="unmute" src="{% static 'images/conversation/icon-microphone-unmute-01.png' %}" alt="mute"/> </span> </div> </div>
this part of javascript. works. can connect room , can share videos between participants.:
var local_participant; var videoroom; $("#call").click(function () { sendnotification("call canceled"); if(videoroom) { videoroom.disconnect(); } }); $("#mute").click(function () { $(this).hide("fast", function () { $("#unmute").show(); local_participant.audiotracks.foreach(function (audiotrack) { audiotrack.enable(); }); }); }); $("#unmute").click(function () { $(this).hide(function () { $("#mute").show(); }); local_participant.audiotracks.foreach(function (audiotrack) { audiotrack.disable(); }); }); twilio.video.connect(doctor_token, {name: room_name}).then(function (room) { videoroom = room; twilio.video.createlocalvideotrack({audio: true}).then(function (localtrack) { localtrack.attach("#localvideo"); room.localparticipant.addtrack(localtrack); local_participant = room.localparticipant; }); room.on('participantconnected', function (participant) { console.log('participant connected: ' + participant.identity); }); room.on('participantdisconnected', function (participant) { console.log('participant disconnected: ' + participant.identity); }); room.on('trackadded', function (track, participant) { console.log(participant.identity + " added track: " + track.kind); track.attach("#patientvideo"); }); room.on('trackremoved', function (track, participant) { console.log(participant.identity + " removed track: " + track.kind); track.detach("#patientvideo"); }); });
twilio developer evangelist here.
in code local user's video track calling:
twilio.video.createlocalvideotrack({audio: true})
however createlocalvideotrack
not create audio tracks. instead, should call createlocaltracks
:
twilio.video.createlocaltracks()
the default options createlocaltracks
{ video: true, audio: true }
should need. promise resolves array of localtracks
need update callback code too.
twilio.video.createlocaltracks().then(function (localtracks) { localtracks.foreach(function(localtrack) { localtrack.attach("#localvideo"); room.localparticipant.addtrack(localtrack); }) local_participant = room.localparticipant; });
let me know if helps!
Comments
Post a Comment