Class: Sound
- Inherits:
-
Object
- Object
- Sound
- Defined in:
- lib/soundplayer.rb
Class Method Summary collapse
Class Method Details
.play(filename, loopx = 1) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/soundplayer.rb', line 14 def self.play(filename, loopx=1) sound = Sound.new(filename) seconds = case File.extname(filename)[1..-1].to_sym when :wav reader = Reader.new(filename) duration = reader.total_duration duration.seconds + (duration.milliseconds) / 1000.0 when :ogg OggInfo.open(filename).length end return loop { sound.play; sleep seconds } if loopx < 1 loopx.times { sound.play; sleep seconds } end |