lib/shelr/player.rb in shelr-0.16.0 vs lib/shelr/player.rb in shelr-0.16.1
- old
+ new
@@ -27,12 +27,16 @@
play_parts_hash(parts)
end
def self.list
(Dir[File.join(Shelr::DATA_DIR, "**")] - ['.', '..']).sort.each do |dir|
- metadata = JSON.parse(IO.read(File.join(dir, 'meta')))
- puts "#{metadata["recorded_at"]} : #{metadata["title"]}"
+ begin
+ metadata = JSON.parse(IO.read(File.join(dir, 'meta')))
+ puts "#{metadata["recorded_at"]} : #{metadata["title"]}"
+ rescue Errno::ENOENT
+ puts "Corrupted shellcast in #{dir}"
+ end
end
end
# TODO: refactore me!
def self.play_parts_hash(parts)
@@ -53,20 +57,20 @@
stop_sound_player
end
def start_sound_player
return unless File.exist?(record_file('sound.ogg'))
- at_exit { system('stty echo') }
+ # at_exit { system('stty echo') }
STDOUT.puts "=> Starting sound player..."
@sox_pid = fork do
`play #{record_file('sound.ogg')} 2>&1`
end
end
def stop_sound_player
return unless File.exist?(record_file('sound.ogg'))
STDOUT.puts "=> Stopping sound player..."
- Process.kill("HUP", @sox_pid)
+ Process.waitpid(@sox_pid)
end
def self.scriptreplay(typescript_file, timing_file)
typescript = File.open(typescript_file)
timing = File.open(timing_file)