Skip to content

Commit cd50070

Browse files
author
Cesar Vargas Casaseca
committed
Added comments and small rename refactor.
1 parent 3b5e350 commit cd50070

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Wyler/SampleApp/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class ViewController: UIViewController {
4242

4343
animateBall()
4444

45-
screenRecorder.startRecording(saveToCameraRoll: cameraRollSwitch.isOn, error: { error in
45+
screenRecorder.startRecording(saveToCameraRoll: cameraRollSwitch.isOn, errorHandler: { error in
4646
debugPrint("Error when recording \(error)")
4747
})
4848
}

Wyler/Wyler/ScreenRecorder.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,25 @@ final public class ScreenRecorder {
1818

1919
public init() {}
2020

21+
/**
22+
Starts recording the content of the application screen. It works together with stopRecording
23+
24+
- Parameter outputURL: The output where the video will be saved. If nil, it saves it in the documents directory.
25+
- Parameter size: The size of the video. If nil, it will use the app screen size.
26+
- Parameter saveToCameraRoll: Whether to save it to camera roll. False by default.
27+
- Parameter errorHandler: Called when an error is found
28+
*/
2129
public func startRecording(to outputURL: URL? = nil,
2230
size: CGSize? = nil,
2331
saveToCameraRoll: Bool = false,
24-
error: @escaping (Error) -> Void) {
32+
errorHandler: @escaping (Error) -> Void) {
2533
if saveToCameraRoll {
2634
checkPhotoLibraryAuthorizationStatus()
2735
}
2836

29-
createVideoWriter(in: outputURL, error: error)
37+
createVideoWriter(in: outputURL, error: errorHandler)
3038
addVideoWriterInput(size: size)
31-
startCapture(error: error)
39+
startCapture(error: errorHandler)
3240
}
3341

3442
private func checkPhotoLibraryAuthorizationStatus() {
@@ -107,6 +115,11 @@ final public class ScreenRecorder {
107115
}
108116
}
109117

118+
/**
119+
Stops recording the content of the application screen, after calling startRecording
120+
121+
- Parameter errorHandler: Called when an error is found
122+
*/
110123
public func stoprecording(errorHandler: @escaping (Error) -> Void) {
111124
RPScreenRecorder.shared().stopCapture( handler: { error in
112125
if let error = error {

0 commit comments

Comments
 (0)