window.show
Thread.new do
song = Gosu::Song.new("file.mp3")
song.play
loop do
song.update
break unless song.playing?
end
end
Gosu::Song
:song = Gosu::Simple.new("file.mp3") # => RuntimeError: File contains data in an unknown format.
Gosu::Song
on a background thread; Gosu is designed to be used on the main thread (for now). However, there is a Gosu::Song.update
method that should be pretty much what you are looking for, if you have a way of regularly calling it from the main thread.class MW < Gosu::Window
def initialize
super 640, 480
@song = Gosu::Song.new("alert2.mp3")
@song.play
end
end
window = MW.new
window.show
if compare_img(img) == :face
Gosu::Song.new("alert2.mp3").play
end
@song.play
, sorry i forgot it.
require "gosu"
tone = Gosu::Sample.new("alert2.mp3").play
# Prevent program from exiting instantly
while(tone.playing?)
sleep 0.1
end
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill