Class: SFML::Music
- Inherits:
-
Object
- Object
- SFML::Music
- Defined in:
- lib/sfml/audio.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_duration ⇒ Object
- #get_loop ⇒ Object
- #get_pitch ⇒ Object
- #get_playing_offset ⇒ Object
- #get_status ⇒ Object
- #get_volume ⇒ Object
-
#initialize(filename) ⇒ Music
constructor
A new instance of Music.
- #pause ⇒ Object
- #play ⇒ Object
- #set_loop(b) ⇒ Object
- #set_pitch(f) ⇒ Object
- #set_playing_offset(time) ⇒ Object
- #set_volume(f) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(filename) ⇒ Music
Returns a new instance of Music.
159 160 161 162 163 |
# File 'lib/sfml/audio.rb', line 159 def initialize(filename) @music = SFMLImporter.sfMusic_createFromFile(filename) raise "Couldn't load #{filename}" if @music.null? ObjectSpace.define_finalizer @music, SFML::Music.dtor end |
Class Method Details
.dtor ⇒ Object
152 153 154 155 156 157 |
# File 'lib/sfml/audio.rb', line 152 def self.dtor proc { |id| SFMLImporter.sfMusic_stop(id) SFMLImporter.sfMusic_destroy(id) } end |
Instance Method Details
#get_duration ⇒ Object
180 181 182 |
# File 'lib/sfml/audio.rb', line 180 def get_duration SFMLImporter.sfMusic_getDuration(@music) / 1000000.0 end |
#get_loop ⇒ Object
168 169 170 |
# File 'lib/sfml/audio.rb', line 168 def get_loop SFMLImporter.sfMusic_getLoop > 0 end |
#get_pitch ⇒ Object
203 204 205 |
# File 'lib/sfml/audio.rb', line 203 def get_pitch SFMLImporter.sfMusic_getPitch(@music) end |
#get_playing_offset ⇒ Object
197 198 199 |
# File 'lib/sfml/audio.rb', line 197 def SFMLImporter.(@music) / 1000000.0 end |
#get_status ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/sfml/audio.rb', line 183 def get_status r = SFMLImporter.sfMusic_getStatus(@music) case r when SFMLImporter::SFSTOPPED :stopped when SFMLImporter::SFPAUSED :paused when SFMLImporter::SFPLAYING :playing end end |
#get_volume ⇒ Object
209 210 211 |
# File 'lib/sfml/audio.rb', line 209 def get_volume SFMLImporter.sfMusic_getVolume(@music) end |
#pause ⇒ Object
174 175 176 |
# File 'lib/sfml/audio.rb', line 174 def pause SFMLImporter.sfMusic_pause(@music) end |
#play ⇒ Object
171 172 173 |
# File 'lib/sfml/audio.rb', line 171 def play SFMLImporter.sfMusic_play(@music) end |
#set_loop(b) ⇒ Object
165 166 167 |
# File 'lib/sfml/audio.rb', line 165 def set_loop(b) SFMLImporter.sfMusic_setLoop(@music, (b ? 1 : 0)) end |
#set_pitch(f) ⇒ Object
200 201 202 |
# File 'lib/sfml/audio.rb', line 200 def set_pitch(f) SFMLImporter.sfMusic_setPitch(@music, f) end |
#set_playing_offset(time) ⇒ Object
194 195 196 |
# File 'lib/sfml/audio.rb', line 194 def (time) SFMLImporter.(@music, time * 1000000.0) end |
#set_volume(f) ⇒ Object
206 207 208 |
# File 'lib/sfml/audio.rb', line 206 def set_volume(f) SFMLImporter.sfMusic_setVolume(@music, f) end |
#stop ⇒ Object
177 178 179 |
# File 'lib/sfml/audio.rb', line 177 def stop SFMLImporter.sfMusic_stop(@music) end |