-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT] move enable sounds to the audio helper class and expose getter and setters to enable and disable toggeable sounds #115
Conversation
@mhuynh5757 can you please do a quick pass? |
…tters to enable and disable toggeable sounds
c4cbec3
to
7fea676
Compare
@@ -359,8 +387,8 @@ class AudioHelper extends EventEmitter { | |||
return enabledSounds[key]; | |||
} | |||
|
|||
Object.keys(enabledSounds).forEach(key => { | |||
(this as any)[key] = setValue.bind(null, key); | |||
Object.keys(enabledSounds).forEach((key: Device.ToggleableSound) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if (options.enabledSounds) { | ||
this._addEnabledSounds(options.enabledSounds); | ||
} | ||
this._addEnabledSounds(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we only call this once at instantiation, and therefore we only add sounds that are enabled at construction time. It's not immediately clear to me that we can enable sounds post-construction, perhaps we need some mechanism for that?
@@ -21,6 +21,12 @@ const kindAliases: Record<string, string> = { | |||
audiooutput: 'Audio Output', | |||
}; | |||
|
|||
export const defaultEnabledSounds: Record<Device.ToggleableSound, boolean> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove these defaults from device
if we want the AudioHelper
class to have more control over the enablement of sounds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, didn't see the device
changes, please ignore this comment! 😓
@@ -972,7 +963,7 @@ class Device extends EventEmitter { | |||
maxAverageBitrate: this._options.maxAverageBitrate, | |||
preflight: this._options.preflight, | |||
rtcConstraints: this._options.rtcConstraints, | |||
shouldPlayDisconnect: () => this._enabledSounds.disconnect, | |||
shouldPlayDisconnect: () => this._audio ? this._audio.disconnect() : defaultEnabledSounds.disconnect, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check if these members are defined, i.e. this._audio.disconnect
might be undefined depending on the state of the AudioHelper
and we might try to invoke it.
@kamalbennani thanks for contributing to the SDK! All feedback is greatly appreciated. I left some comments on some more specific details. One recommendation over the current implementation that I'd like to see change is moving away from setting
or maybe we relegate all "shouldPlay" logic to the What do you think? |
@kamalbennani I'm closing this now. See my comment here #14 (comment) |
The goal of this PR is to answer the "lack of implementation" described in this issue
Contributing to Twilio
Pull Request Details
JIRA link(s):
Description
This PR introduces a couple of changes:
this.audio.outgoing
instead of relying on the enabledSounds private propertyBurndown
Before review
npm test
Before merge