diff options
| author | Heitor Carvalho <[email protected]> | 2018-10-24 18:10:17 -0300 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2018-10-24 14:10:16 -0700 |
| commit | 830d99fde4555263967dfee94b4095ee300c12e1 (patch) | |
| tree | 8360ba4b8bc60a45fd50c484f4de39dee13246cd /lib | |
| parent | 1b646f82c67e7c38df08113bcc3323c7aaf4639f (diff) | |
| download | ruby2d-830d99fde4555263967dfee94b4095ee300c12e1.tar.gz ruby2d-830d99fde4555263967dfee94b4095ee300c12e1.zip | |
Implements volume control to Music (#123)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ruby2d/music.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/ruby2d/music.rb b/lib/ruby2d/music.rb index 41b8901..5974a8a 100644 --- a/lib/ruby2d/music.rb +++ b/lib/ruby2d/music.rb @@ -39,6 +39,22 @@ module Ruby2D ext_stop end + # Returns the previous volume setting, in percentage + def self.volume + self.ext_volume(-1) + end + + # Set music volume, 0 to 100% + def self.volume=(v) + # If a negative value, volume will be 0 + if v < 0 then v = 0 end + self.ext_volume(v) + end + + # Alias instance methods to class methods + def volume; Music.volume end + def volume=(v); Music.volume=(v) end + # Fade out music over provided milliseconds def fadeout(ms) ext_fadeout(ms) |
