Ciao a tutti
ho abbozzato un semplice lettore audio usango ruby-gtk e ruby-gstreamer
il
problema è che non riesco a usare la classe Gst::Thread mi da sempre
questo
errore :
./M.audio.rb:31:in play': uninitialized constant Gst::Thread from ./M.audio.rb:58 from ./M.audio.rb:62:in
call’
from ./M.audio.rb:62:in `main’
from ./M.audio.rb:62
qualche dritta?
Grazie
di seguito c’è il codice:
#!/usr/bin/env ruby
require ‘gst’
require ‘gtk2’
class Player
@stopped = 0
def initialize
@pipeline = Gst::Pipeline.new
@src = Gst::ElementFactory.make("filesrc")
@dec = Gst::ElementFactory.make("mad")
@sink = Gst::ElementFactory.make("autoaudiosink")
@pipeline.add(@src, @dec, @sink)
@src >> @dec >> @sink
end
def get_song
if ARGV.size != 1
puts "Troppe Canzoni"
exit
end
@song = ARGV.first
@src.location = @song
end
def play
Thread.new do
while @stopped != 1
@pipeline.play
end
end
end
def pause
@stopped = 0
@pipeline.pause
end
end
Gst.init
P = Player.new
P.get_song
window = Gtk::Window.new(‘Player’)
window.border_width = 10
window.resizable = true
window.window_position = Gtk::Window::POS_CENTER
button = Gtk::Button.new(‘play’)
button.signal_connect(‘clicked’){ P.play }
window.signal_connect(‘destroy’){ Gtk.main_quit }
window.add(button)
window.show_all
Gtk.main