Skip to content

Commit

Permalink
Merge pull request #42 from TECH7Fox/mute-button
Browse files Browse the repository at this point in the history
Add mute button
  • Loading branch information
TECH7Fox authored Mar 6, 2022
2 parents 018132c + a43d919 commit 044c5a2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/sipjs-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ class SipJsCard extends LitElement {
</ha-icon-button>
<span id="name" class="title">Idle</span>
</div>
<div class="row">
<ha-icon-button
.label=${"Mute"}
@click="${this._toggleMute}"
><ha-icon id="mute-icon" icon="hass:microphone"></ha-icon>
</ha-icon-button>
</div>
<div class="row">
${this.config.dtmfs ?
this.config.dtmfs.map(dtmf => {
Expand Down Expand Up @@ -376,6 +383,20 @@ class SipJsCard extends LitElement {
await this.simpleUser.hangup();
}

async _toggleMute() {
const pc: any = this.simpleUser.session.sessionDescriptionHandler.peerConnection
pc.getSenders().forEach((stream: any) => {
stream.track.enabled = !stream.track.enabled;
console.log(stream.track.enabled);
if (stream.track.enabled) {
this.renderRoot.querySelector('#mute-icon').icon = "hass:microphone";
} else {
this.renderRoot.querySelector('#mute-icon').icon = "hass:microphone-off";
}
});

}

async _sendDTMF(signal) {
await this.simpleUser.sendDTMF(signal);
}
Expand Down

0 comments on commit 044c5a2

Please sign in to comment.