Class: ScreenRecorder::Common Private
- Inherits:
-
Object
- Object
- ScreenRecorder::Common
- Defined in:
- lib/screen-recorder/common.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- PROCESS_TIMEOUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Seconds to wait for ffmpeg to quit
5
Instance Attribute Summary collapse
- #options ⇒ Object readonly private
- #video ⇒ Object readonly private
Instance Method Summary collapse
-
#discard ⇒ Object
(also: #delete)
private
Discards the recorded file.
-
#initialize(input:, output:, advanced: {}) ⇒ Common
constructor
private
A new instance of Common.
-
#start ⇒ Object
private
Starts the recording.
-
#stop ⇒ Object
private
Stops the recording.
Constructor Details
#initialize(input:, output:, advanced: {}) ⇒ Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Common.
11 12 13 14 15 16 17 |
# File 'lib/screen-recorder/common.rb', line 11 def initialize(input:, output:, advanced: {}) raise Errors::DependencyNotFound unless ffmpeg_exists? @options = Options.new(input: input, output: output, advanced: advanced) @video = nil @process = nil end |
Instance Attribute Details
#options ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/screen-recorder/common.rb', line 9 def @options end |
#video ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/screen-recorder/common.rb', line 9 def video @video end |
Instance Method Details
#discard ⇒ Object Also known as: delete
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Discards the recorded file. Useful in automated testing when a test passes and the recorded file is no longer needed.
48 49 50 |
# File 'lib/screen-recorder/common.rb', line 48 def discard File.delete .output end |
#start ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Starts the recording
22 23 24 25 26 27 28 |
# File 'lib/screen-recorder/common.rb', line 22 def start ScreenRecorder.logger.debug 'Starting recorder...' @video = nil # New file @process = start_ffmpeg ScreenRecorder.logger.info 'Recording...' @process end |
#stop ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Stops the recording
33 34 35 36 37 38 39 40 41 |
# File 'lib/screen-recorder/common.rb', line 33 def stop ScreenRecorder.logger.debug 'Stopping ffmpeg...' exit_code = stop_ffmpeg return if exit_code == 1 # recording failed ScreenRecorder.logger.debug 'Stopped ffmpeg.' ScreenRecorder.logger.info 'Recording complete.' @video = prepare_video unless exit_code == 1 end |