Skip to content

Commit

Permalink
Fix player
Browse files Browse the repository at this point in the history
  • Loading branch information
Antono Vasiljev committed Apr 23, 2012
1 parent 2a1b1fd commit 94306b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions lib/shelr/player.rb
Expand Up @@ -58,30 +58,27 @@ def initialize(id)

def play
Shelr.terminal.puts_line
system(scriptreplay_cmd)
self.class.scriptreplay record_file('typescript'), record_file('timing')
Shelr.terminal.puts_line
end

private

def scriptreplay(typescript_file, timing_file)
def self.scriptreplay(typescript_file, timing_file)
typescript = File.open(typescript_file)
timing = File.open(timing_file)
frames = timing.read.split("\n").map { |line| line.split(" ") }
frames.map! { |k,v| [k.to_f.abs, v.to_i] }
typescript.gets # skip first line

frames.each do |usec,length|
sleep(usec.to_f)
print typescript.read(length.to_i)
sleep(usec)
print typescript.read(length)
end
end

private

def record_file(name)
File.join(Shelr.data_dir(@record_id), name)
end

def scriptreplay_cmd
scriptreplay record_file('typescript'), record_file('timing')
end
end
end
2 changes: 1 addition & 1 deletion lib/shelr/version.rb
@@ -1,3 +1,3 @@
module Shelr
VERSION = '0.15.0'
VERSION = '0.15.1'
end

0 comments on commit 94306b3

Please sign in to comment.