Skip to content
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

[FEATURE] Provide a way to force stop sounds #222

Closed
aburkowsky9 opened this issue Nov 30, 2023 · 7 comments
Closed

[FEATURE] Provide a way to force stop sounds #222

aburkowsky9 opened this issue Nov 30, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@aburkowsky9
Copy link

aburkowsky9 commented Nov 30, 2023

Is your feature request related to a problem? Please describe.
For various reasons there are instances of the device continuing to play sounds like the Incoming ringing sound after answering, ending, or rejecting a call. The only remedy I am currently aware of outside of a larger refactor is to access the private property _soundcache on the Device and stop the sound using something like the following:

  const stopIncomingCallSound = useCallback(() => {
    const soundCache: Map<Device.SoundName, { stop: () => void }> | undefined =  state.device?._soundcache;
    soundCache?.get(Device.SoundName.Incoming)?.stop();
  }, [state.device]);

Describe the solution you'd like
This is clearly undesirable since the _soundcache property is private and should be inaccessible. Im sure direct access is not a stable feature. It would be much better to have an exposed method on the Device or Call instance to force change in play state of a sound.

Describe alternatives you've considered
Clearly there are other issues causing this kind of behavior. Largely there are some architectural concerns that will take time to implement on our side, but there is also the possibility of an existing bug in the SDK itself, but this seems like a reasonable feature to provide as an escape hatch.

device?.audio?.incoming(false);

While the method on the audio property is available to disable sounds is available this method doesn't seem to work with my specific case and it's also problematic in that I would have to reenable the sound at some point.

Additional context
None

@aburkowsky9 aburkowsky9 added the enhancement New feature or request label Nov 30, 2023
@aburkowsky9 aburkowsky9 changed the title [FEATURE] Provide a way to turn stop sounds [FEATURE] Provide a way to force stop sounds Nov 30, 2023
@charliesantos
Copy link
Collaborator

@aburkowsky9 thanks for reaching out. We will consider this feature request.
Regarding the issue where sometimes the sounds won't stop playing, do you have any reproduction steps so we can take a look at?

@aburkowsky9
Copy link
Author

aburkowsky9 commented Nov 30, 2023

@charliesantos thank you.

I think it would be pretty difficult for you to reproduce but Im happy to schedule a screenshare session with a dev if you'd like. Im currently facing a bug when a user attempts to change their worker activity to Offline through the task router SDK when they have a pending reservation. The task router SDK receives an error to which I am able to handle properly. I cannot identify any real effect on the voice SDK Device or Call instances so I'm not sure where things are going wrong there. The only oddity I have identified is occasionally in this case I see the incoming event get triggered on the Device several times, but just as often its triggered only once as during normal flows. In either case, I only ever see one Call instance in calls array on the Device.

@charliesantos
Copy link
Collaborator

@aburkowsky9 this complicates things since there's a task router SDK involved. To better isolate the issue, can you try to reproduce using our Voice JS SDK quickstart https://www.twilio.com/docs/voice/sdks/javascript/get-started?

@aburkowsky9
Copy link
Author

@charliesantos I will give it a shot if I find sometime next week, but im not necessarily looking for help identifying a fix for the bug. Im not sure that it would be easily replicable in a quick start app and it could just become its own wormhole. Largely, I just think this feature request could help the user experience of this SDK.

@charliesantos
Copy link
Collaborator

@aburkowsky9 I understand. The feature is being considered.
Please let me know how it goes once you're able to try the quickstart.

@ealexseen
Copy link

ealexseen commented Jan 11, 2024

Can you add two methods for Device class?

Because _soundcache have private

image

I need public methods to change the audio state (stop or play)

// types
soundCachePlay(key: Device.SoundName): void;
soundCacheStop(key: Device.SoundName): void;

// methods for Device
soundCachePlay = (key: Device.SoundName) => {
   if (key) this._soundcache.get(key).play()
}
soundCacheStop = (key: Device.SoundName) => {
   if (key) this._soundcache.get(key).stop()
}

@charliesantos
Copy link
Collaborator

Closing this now. We're tracking this feature request internally. Please feel free to follow up if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants