Class: Camtasy::Preview

Inherits:
Object
  • Object
show all
Defined in:
lib/camtasy/preview.rb

Instance Method Summary collapse

Instance Method Details

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/camtasy/preview.rb', line 6

def run
  session = AVCapture::Session.new
  dev = AVCapture.devices.find(&:video?)

  session.run_with(dev) do |connection|
    loop do
      case $stdin.getch
      when 'q' then break # quit when you hit 'q'
      else
        IO.popen("open -g -f -a /Applications/Preview.app", 'w') do |f|
          f.write connection.capture
        end
      end
    end
  end
end