Jitsi widget supports muting/unmuting at will

This commit is contained in:
Andrew Morgan 2018-11-01 19:48:05 +01:00
parent c811b273dd
commit 8eb52712bf

View File

@ -46,10 +46,38 @@ export class JitsiWidgetWrapperComponent extends CapableWidget implements OnInit
$.getScript(widget.options.scriptUrl); $.getScript(widget.options.scriptUrl);
}); });
this.jitsiApiSubscription = ScalarWidgetApi.requestReceived.subscribe(request => { this.jitsiApiSubscription = ScalarWidgetApi.requestReceived.subscribe(request => {
if (request.action === "audioMuteToggle" && this.isJoined) { if (!this.isJoined) {
this.jitsiApiObj.executeCommand('toggleAudio'); return;
ScalarWidgetApi.replyAcknowledge(request);
} }
switch (request.action) {
case "audioToggle":
this.jitsiApiObj.executeCommand('toggleAudio');
break;
case "audioMute":
this.jitsiApiObj.isAudioMuted().then((muted) => {
// Toggle audio if Jitsi is not currently muted
if (!muted) {
this.jitsiApiObj.executeCommand('toggleAudio');
}
});
break;
case "audioUnmute":
this.jitsiApiObj.isAudioMuted().then((muted) => {
// Toggle audio if Jitsi is currently muted
if (muted) {
this.jitsiApiObj.executeCommand('toggleAudio');
}
});
break;
default:
// Unknown command sent
return;
}
// TODO: Travis, should this fire even if we didn't get a command we're
// handling?
ScalarWidgetApi.replyAcknowledge(request);
}); });
} }