Reputation: 4588
I am experimenting with ruby and found a gui toolkit called Shoes.
I am using Windows 8 and I would like to create a button in Shoes and have it play an audio file when clicked.
The non-shoes ruby code I am using is the following. Keep in mind that for this to work I had to installed this gem: https://rubygems.org/gems/win32-sound
require 'win32/sound'
include Win32
puts "Hit Enter"
makeSound = gets.chomp
while makeSound
Sound.play('c:\users\william\desktop\oink.wav')
makeSound = gets.chomp
end
The code I am attempting to launch with Shoes is:
require 'win32/sound'
include Win32
Shoes.app {
@push = button "Push me"
@push.click {
Sound.play('c:\users\william\desktop\oink.wav')
}
}
Now of course this does not work but I am inquiring as to how to approach and/or remedy this problem.
Upvotes: 3
Views: 284
Reputation: 1624
I assume that you are using Red Shoes (which is apparent from the above snapshot). Shoes would not be able to require the gems that you have installed in your machine directly. You need to tell Shoes extensively that you are going to use some gem and let shoes set it up before app starts.
You can do it in following way, put the below code at top of your shoes code:
Shoes.setup do
gem 'win32-sound'
end
#Now you can require gem and do the rest as you need...
require 'win32/sound'
include Win32
Hope it helps :)
Upvotes: 1