class ScreenRecorder
Attributes
video_path[RW]
USAGE: @tape = ScreenRecorder.new
# start a recording with @tape.record # stop it: @tape.stop
Public Class Methods
new(video_path="video_recording.mov")
click to toggle source
# File lib/project/screen_recorder.rb, line 11 def initialize(video_path="video_recording.mov") setup_video setup_recording @video_path = NSURL.fileURLWithPath(video_path) end
Public Instance Methods
record()
click to toggle source
# File lib/project/screen_recorder.rb, line 17 def record @captureMovieFileOutput.startRecordingToOutputFileURL(video_path, recordingDelegate:self) end
setup_recording()
click to toggle source
# File lib/project/screen_recorder.rb, line 33 def setup_recording @captureMovieFileOutput = AVCaptureMovieFileOutput.alloc.init @captureMovieFileOutput.setDelegate(self) if @session.canAddOutput(@captureMovieFileOutput) @session.addOutput(@captureMovieFileOutput) end end
setup_video()
click to toggle source
# File lib/project/screen_recorder.rb, line 25 def setup_video @session = AVCaptureSession.alloc.init @session.sessionPreset = AVCaptureSessionPresetHigh device = AVCaptureScreenInput.alloc.initWithDisplayID(CGMainDisplayID()) @session.addInput(device) @session.startRunning() end
stop()
click to toggle source
# File lib/project/screen_recorder.rb, line 21 def stop @captureMovieFileOutput.stopRecording end