Class: EmulatorRecorder
- Inherits:
-
Object
- Object
- EmulatorRecorder
- Defined in:
- lib/capa/emulator_recorder.rb
Instance Method Summary collapse
-
#initialize(filename: '') ⇒ EmulatorRecorder
constructor
A new instance of EmulatorRecorder.
- #pull_video_from_emulator ⇒ Object
- #record ⇒ Object
Constructor Details
#initialize(filename: '') ⇒ EmulatorRecorder
Returns a new instance of EmulatorRecorder.
5 6 7 8 |
# File 'lib/capa/emulator_recorder.rb', line 5 def initialize(filename: '') abort('Please provide a name for the video') if filename.blank? @filename = filename end |
Instance Method Details
#pull_video_from_emulator ⇒ Object
33 34 35 36 |
# File 'lib/capa/emulator_recorder.rb', line 33 def pull_video_from_emulator # We can specify the device, in case there is more than one connected: -s emulator-5554 puts `adb pull #{emulator_video_path}` end |
#record ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/capa/emulator_recorder.rb', line 10 def record abort("You need exactly one emulator or device connected") unless can_record? Signal.trap("SIGINT") { raise Capa::UserAbort } Signal.trap("SIGTSTP") { raise Capa::UserAbort } Thread.new do # Might want to add '--size 720x1280' flag. That's the maximum permitted size for video recordings # We can specify the device, in case there is more than one connected: -s emulator-5554 = `adb shell screenrecord --verbose #{emulator_video_path}` abort("Maximum permitted resolution is 720x1280. Minimum Android version is Marshmallow.\n"\ "Please choose a different device.\n"\ "Tip: Galaxy Nexus works great!") if /err=-38/ =~ end puts 'Capturing video... Press ENTER to save' p = gets.chomp `adb shell killall -SIGINT screenrecord` sleep 0.5 pull_video_from_emulator end |