Sha256: 5cf1e02c5a2e1da8acf23802e35a456ee370ed399722d839d3e6f971b6583cb0
Contents?: true
Size: 1.55 KB
Versions: 4
Compression:
Stored size: 1.55 KB
Contents
#!/usr/bin/env ruby require 'rubygame' Rubygame.init() def test_music() mix = Rubygame::Mixer # Use the lines below to get rid of artsd and contact ALSA directly on Linux. # ARTSD happens to be buggy on my old, old linux distro. if false if RUBY_PLATFORM =~ /linux/ `killall artsd` ENV['SDL_AUDIODRIVER'] = "alsa" end end mix.open_audio puts "Using audio driver:" + mix.driver_name music = mix::Music if ARGV[0] file = ARGV[0] else file = "song.ogg" puts "If you want, you could give a filename as an argument to this script." end mus = music.load_audio(file); puts "Testing fading in over 3 seconds, repeating forever." mus.fade_in(3, -1); puts('ERROR: Music not fading in') unless mus.fading?(:in) sleep 3 puts "Playing for 2 seconds." sleep 2 puts "Lowering volume to half for 3 seconds." mus.volume = 0.5; puts "ERROR: Volume wasn't adjusted" unless mus.volume == 0.5 sleep 3 puts "Restoring volume to full." mus.volume = 1.0; sleep 2 puts "Pausing for 1 seconds." mus.pause puts "ERROR: Music not paused." unless mus.paused? sleep 1 puts "Resuming." mus.resume puts "ERROR: Music not resumed" unless mus.playing? puts "Playing for 2 seconds." sleep 2 puts "Fading out over 2 seconds." mus.fade_out(2); puts "ERROR: Music not fading out " unless mus.fading?(:out) while mus.playing? or mus.fading? == :out do Thread.pass end # Test playing of music to the end puts "ERROR: Music not ended" if mus.playing? mix.close_audio end music_thread = Thread.new do test_music() end music_thread.join Rubygame.quit()
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rubygame-2.2.0-mswin32 | samples/demo_music.rb |
rubygame-2.2.0-i586-linux | samples/demo_music.rb |
rubygame-2.1.0 | samples/demo_music.rb |
rubygame-2.2.0 | samples/demo_music.rb |