-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[Merged by Bors] - Add a way to toggle AudioSink
#6321
Conversation
Signed-off-by: Lena Milizé <[email protected]>
Code is correct, and docs are good. Unsure about adding non-idempotent methods, but users will want this. Would you use this for e.g. "disable all dialogue" buttons in menus? |
Signed-off-by: Lena Milizé <[email protected]>
Right now in my game I have a persistent background music (similar to Stellaris' music player), and use this for a "Toggle music" button in options menu. |
I am okay with this change, but note that |
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.
Maybe the use case isn't broad, but it won't hurt to have this feature.
Sure, why not. This is a common pattern. bors r+ |
# Objective Currently toggling an `AudioSink` (for example from a game menu) requires writing ```rs if sink.is_paused() { sink.play(); } else { sink.pause(); } ``` It would be nicer if we could reduce this down to a single line ```rs sink.toggle(); ``` ## Solution Add an `AudioSink::toggle` method which does exactly that. --- ## Changelog - Added `AudioSink::toggle` which can be used to toggle state of a sink.
AudioSink
AudioSink
# Objective Currently toggling an `AudioSink` (for example from a game menu) requires writing ```rs if sink.is_paused() { sink.play(); } else { sink.pause(); } ``` It would be nicer if we could reduce this down to a single line ```rs sink.toggle(); ``` ## Solution Add an `AudioSink::toggle` method which does exactly that. --- ## Changelog - Added `AudioSink::toggle` which can be used to toggle state of a sink.
Objective
Currently toggling an
AudioSink
(for example from a game menu) requires writingIt would be nicer if we could reduce this down to a single line
Solution
Add an
AudioSink::toggle
method which does exactly that.Changelog
AudioSink::toggle
which can be used to toggle state of a sink.