Sha256: dd97931933f5e32d9d9c0d291d698e9aca8de651aa8b55dc439cf08d2b1ff6f2

Contents?: true

Size: 711 Bytes

Versions: 53

Compression:

Stored size: 711 Bytes

Contents

# Plays simple sounds from .wav files
class Wx::Sound
  class << self
    # Shortcut class method, as per the wxWidgets docs, but easier to do
    # in Ruby
    def play(file, flags = Wx::SOUND_ASYNC)
      new(file).play(flags)
    end
  end

  # Test if newly created Sound is valid; if not, raise an exception
  # rather than failing silently.
  wx_init = self.instance_method(:initialize)
  define_method(:initialize) do | *args |
    if not File.exist?( File.expand_path(args[0]) )
      Kernel.raise(ArgumentError, "Sound file does not exist: #{args[0]}")
    end
    wx_init.bind(self).call(*args)
    if not ok?
      Kernel.raise(ArgumentError, "Error loading sound file #{args[0]}")
    end
  end
end

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
wxruby-1.9.4-x86_64-linux lib/wx/classes/sound.rb
wxruby-1.9.5-universal-darwin-9 lib/wx/classes/sound.rb
wxruby-1.9.5-x86-linux lib/wx/classes/sound.rb
wxruby-1.9.5-x86_64-linux lib/wx/classes/sound.rb
wxruby-1.9.6-universal-darwin-9 lib/wx/classes/sound.rb
wxruby-1.9.6-x86-linux lib/wx/classes/sound.rb
wxruby-1.9.6-x86-mswin32-60 lib/wx/classes/sound.rb
wxruby-1.9.6-x86-mingw32 lib/wx/classes/sound.rb
wxruby-1.9.7-universal-darwin-9 lib/wx/classes/sound.rb
wxruby-1.9.7-x86-linux lib/wx/classes/sound.rb
wxruby-1.9.7-x86-mswin32-60 lib/wx/classes/sound.rb
wxruby-1.9.8-universal-darwin-9 lib/wx/classes/sound.rb
wxruby-1.9.8-x86-mingw32 lib/wx/classes/sound.rb
wxruby-1.9.8-x86-linux lib/wx/classes/sound.rb
wxruby-1.9.8-x86-mswin32-60 lib/wx/classes/sound.rb
wxruby-1.9.8-x86_64-linux lib/wx/classes/sound.rb
wxruby-1.9.9-universal-darwin-9 lib/wx/classes/sound.rb
wxruby-1.9.9-x86-linux lib/wx/classes/sound.rb
wxruby-1.9.9-x86-mingw32 lib/wx/classes/sound.rb
wxruby-2.0.0-universal-darwin-9 lib/wx/classes/sound.rb