class Sound
Public Class Methods
play(filename, loopx=1)
click to toggle source
# 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