最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to mute twilio calls in javascript - Stack Overflow

programmeradmin2浏览0评论

I am able to mute the sound going into the microphone, but not the sound ing out of the speakers. To be specific, I'm only trying to mute the Twilio call, not other sounds in the browser, and certainly not system sounds.

I am able to mute the sound going into the microphone, but not the sound ing out of the speakers. To be specific, I'm only trying to mute the Twilio call, not other sounds in the browser, and certainly not system sounds.

Share Improve this question asked Sep 26, 2013 at 18:19 TrevorTrevor 13.5k13 gold badges82 silver badges103 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

Its straightforward using the Javascript 1.4 library, without needing conference calls etc.

https://www.twilio./docs/api/client/connection

e.g.

Twilio.Device.activeConnection().mute(true);

if the call is between 2 persons only, then this can be done by creating a conference in twilio and muting the other person during the call. This will make the server reject the voice input from the other party.

However, to pletely stop the sound on your side local, i would suggest using javascript to alter the flash player privileges to restrict the hardware access when you want the call to be muted.

Here is working example

  $scope.togglePublishAudio = function togglePublishAudio() {
      $log.debug('Toggling publish audio');

      if (activeRoom.localParticipant.media.isMuted === false) {        
        $scope.isMuted = true;        
        activeRoom.localParticipant.media.mute();
      } else {
        $scope.isMuted = false;
        activeRoom.localParticipant.media.unmute();
      }

    };

In new Version of twilio

  var localMedia = room.localParticipant;
  localMedia.tracks.forEach(function (track) {
    if (track.isEnabled) {
      track.disable();
      $scope.isPaused = true;
    } else {
      track.enable();
      $scope.isPaused = false;
    }
  });
发布评论

评论列表(0)

  1. 暂无评论