Class: PlayMp3Audio
- Inherits:
-
Object
- Object
- PlayMp3Audio
- Defined in:
- lib/simple_gui_creator/play_mp3_audio.rb
Instance Method Summary collapse
-
#initialize(filename) ⇒ PlayMp3Audio
constructor
does not work with .wav, unfortunately…
- #join ⇒ Object
- #play_till_end ⇒ Object
- #start ⇒ Object (also: #play_non_blocking)
- #stop ⇒ Object
Constructor Details
#initialize(filename) ⇒ PlayMp3Audio
does not work with .wav, unfortunately…
9 10 11 |
# File 'lib/simple_gui_creator/play_mp3_audio.rb', line 9 def initialize filename # does not work with .wav, unfortunately... @filename = filename end |
Instance Method Details
#join ⇒ Object
23 24 25 |
# File 'lib/simple_gui_creator/play_mp3_audio.rb', line 23 def join @thread.join end |
#play_till_end ⇒ Object
27 28 29 30 |
# File 'lib/simple_gui_creator/play_mp3_audio.rb', line 27 def play_till_end start join end |
#start ⇒ Object Also known as: play_non_blocking
13 14 15 16 17 18 19 20 21 |
# File 'lib/simple_gui_creator/play_mp3_audio.rb', line 13 def start raise 'file not found?' unless File.exist? @filename fis = java.io.FileInputStream.new(@filename) bstream = java.io.BufferedInputStream.new(fis) @player = Player.new(bstream) @thread = Thread.new { @player.play } end |
#stop ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/simple_gui_creator/play_mp3_audio.rb', line 34 def stop if @player @player.close # at least they give us this method yikes @player = nil end # raising here means you didn't call end |