Skip to content

Commit

Permalink
Merge pull request #112 from open-voip-alliance/localstream-added-to-…
Browse files Browse the repository at this point in the history
…disconnect-on-mute

Localstream added to disconnect on mute
  • Loading branch information
Dagg-h authored Jun 3, 2022
2 parents 3ec5e4e + fe44f2c commit 90ce09d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions demo/components/c-session.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,16 @@ window.customElements.define(
}
break;
case 'hold':
this.setMute(true);
this.session && this.session.hold();
break;
case 'unhold':
this.setMute(false);
this.session && this.session.unhold();
break;
case 'toggleMute':
this.toggleMute();
break;
case 'hangup':
this.session && (await this.session.terminate());
break;
Expand All @@ -92,6 +97,16 @@ window.customElements.define(
}
}

toggleMute() {
if (this.session) {
this.session.media.input.muted = !this.session.media.input.muted;
}
}

setMute(mute) {
this.session.media.input.muted = mute;
}

connectedCallback() {
const template = document.querySelector('[data-component=c-session]');
this.appendChild(template.content.cloneNode(true));
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webphone-lib",
"version": "0.2.19-beta.1",
"version": "0.2.20",
"description": "Webphone Lib",
"author": "Open VoIP Alliance",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/session-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class SessionMedia extends EventEmitter implements ISessionMedia {
private setInputMuted(newMuted: boolean) {
if (this.inputNode) {
if (newMuted) {
this.inputNode.disconnect();
this.inputNode.disconnect((this.session as any).__streams.localStream);
} else {
this.inputNode.connect((this.session as any).__streams.localStream);
}
Expand Down

0 comments on commit 90ce09d

Please sign in to comment.