]> git.r.bdr.sh - rbdr/captura/blob - Captura/Scripting/RecordCommand.swift
9d25b59f28480b6ec5d9c99cff40dc089f8b0bef
[rbdr/captura] / Captura / Scripting / RecordCommand.swift
1 import Foundation
2
3 @objc(RecordCommand)
4 class RecordCommand: NSScriptCommand {
5 override func performDefaultImplementation() -> Any? {
6
7 let args = self.directParameter as? [String: Any] ?? [:]
8
9 // Here you can extract the parameters from the args dictionary and configure your settings
10 let x = args["x"] as? Int
11 let y = args["y"] as? Int
12 let width = args["width"] as? Int
13 let height = args["height"] as? Int
14 let preventResize = args["prevent_resize"] as? Bool
15 let preventMove = args["prevent_move"] as? Bool
16 let fps = args["fps"] as? Int
17 let outputs = OutputFormatSetting(args["outputs"] as? String ?? "")
18 let backend = URL(string: args["backend"] as? String ?? "")
19 let backendOutput = OutputFormatSetting(args["backend_output"] as? String ?? "")
20 let keepLocalFiles = args["keep_local_files"] as? Bool
21 let autoStart = args["auto_start"] as? Bool
22 let maxLength = args["max_length"] as? Int
23
24 var skipBackend = false
25 if let backendString = args["backend"] as? String {
26 if backendString == "" {
27 skipBackend = true
28 }
29 }
30
31 let config = RecordAction(
32 action: "record",
33 x: x,
34 y: y,
35 width: width,
36 height: height,
37 preventResize: preventResize,
38 preventMove: preventMove,
39 fps: fps,
40 outputs: outputs,
41 backend: backend,
42 backendOutput: backendOutput,
43 keepLocalFiles: keepLocalFiles,
44 autoStart: autoStart,
45 skipBackend: skipBackend,
46 maxLength: maxLength
47 )
48
49 NotificationCenter.default.post(name: .setCaptureSessionConfiguration, object: nil, userInfo: [
50 "config": config
51 ])
52 NotificationCenter.default.post(name: .startAreaSelection, object: nil, userInfo: nil)
53
54 // Return a result if needed
55 return nil
56 }
57 }