Revision: 4685
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 15, 2008 13:22 by peleteiro
Initial Code
require 'rubygems'
class Player
@@sound_path = ''
@@sound_app = 'mpg321'
@@process_devnull = '> /dev/null 2>&1'
@@process_bg = '&'
def self.sound_path=(value)
@@sound_path = value
end
def self.sound_app=(value)
@@sound_app = value
end
def self.process_devnull=(value)
@@process_devnull = value
end
def self.process_bg=(value)
@@process_bg = value
end
def self.play(file)
cmd = "#{@@sound_app} #{@@sound_path + file} #{@@process_devnull} #{@@process_bg}"
system cmd
end
end
files = Dir.glob(File.join("/home/buildmaster/Desktop/sounds/error", "*.mp3"))
Player.play(files[rand(files.size)])
Initial URL
Initial Description
Initial Title
Play a file using ruby
Initial Tags
Initial Language
Ruby