Skip to content

Commit 9309544

Browse files
authored
Merge pull request #5 from samridhgupta/fix/recording-name-sort
Fix/recording name sort
2 parents 0344ec6 + 9f56878 commit 9309544

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

ios/RNReactNativeReplaykit.m

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ - (dispatch_queue_t)methodQueue
2222

2323
RCT_EXPORT_METHOD(startRecording:(RCTResponseSenderBlock)callback)
2424
{
25-
static NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
26-
NSMutableString *randomString = [NSMutableString stringWithCapacity: 15];
27-
for (int i=0; i<15; i++) {
28-
[randomString appendFormat: @"%C", [letters characterAtIndex: arc4random() % [letters length]]];
29-
}
25+
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
26+
NSNumber *timeStampObj = [NSNumber numberWithInteger: [[NSNumber numberWithDouble: timeStamp] integerValue] ];
27+
NSMutableString *fileName = [[NSMutableString alloc] initWithString:@"Recording-"];
28+
[fileName appendString: [timeStampObj stringValue]];
3029

3130
[self.screenRecordCoordinator
32-
startRecordingWithFileName:randomString
31+
startRecordingWithFileName:fileName
3332
recordingHandler:^(NSError *error) {
3433
if(error)
3534
{

ios/RNReactNativeReplaykit.xcodeproj/project.pbxproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
TargetAttributes = {
110110
58B511DA1A9E6C8500147676 = {
111111
CreatedOnToolsVersion = 6.1.1;
112-
LastSwiftMigration = 0940;
112+
LastSwiftMigration = 1010;
113113
};
114114
};
115115
};
@@ -255,7 +255,8 @@
255255
SWIFT_OBJC_BRIDGING_HEADER = "RNReactNativeReplaykit-Bridging-Header.h";
256256
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
257257
SWIFT_PRECOMPILE_BRIDGING_HEADER = YES;
258-
SWIFT_VERSION = 3.0;
258+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
259+
SWIFT_VERSION = 4.2;
259260
};
260261
name = Debug;
261262
};
@@ -278,7 +279,8 @@
278279
SKIP_INSTALL = YES;
279280
SWIFT_OBJC_BRIDGING_HEADER = "RNReactNativeReplaykit-Bridging-Header.h";
280281
SWIFT_PRECOMPILE_BRIDGING_HEADER = YES;
281-
SWIFT_VERSION = 3.0;
282+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
283+
SWIFT_VERSION = 4.2;
282284
};
283285
name = Release;
284286
};

ios/ScreenRecord/FileUtil.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ import Foundation
7676
let urls = directoryContents.map({
7777
(url: URL) -> String in
7878
return url.relativePath
79-
})
80-
return urls
79+
}).sorted(by: >);
80+
return urls;
8181
}
8282
}
8383

ios/ScreenRecord/ScreenRecordCoordinator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import AVKit
2727

2828
func startRecording(withFileName fileName: String, recordingHandler: @escaping (Error?) -> Void,onCompletion: @escaping (Error?)->Void)
2929
{
30-
self.viewOverlay.show()
30+
// self.viewOverlay.show()
3131
screenRecorder.startRecording(withFileName: fileName) { (error) in
3232
recordingHandler(error)
3333
self.recordCompleted = onCompletion
@@ -37,7 +37,7 @@ import AVKit
3737
func stopRecording()
3838
{
3939
screenRecorder.stopRecording { (error) in
40-
self.viewOverlay.hide()
40+
// self.viewOverlay.hide()
4141
self.recordCompleted?(error)
4242
}
4343
}

ios/ScreenRecord/ScreenRecorder.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import AVKit
2424
{
2525
let fileURL = URL(fileURLWithPath: ReplayFileUtil.filePath(fileName))
2626
assetWriter = try! AVAssetWriter(outputURL: fileURL, fileType:
27-
AVFileTypeMPEG4)
27+
AVFileType.mp4)
2828
let videoOutputSettings: Dictionary<String, Any> = [
2929
AVVideoCodecKey : AVVideoCodecType.h264,
3030
AVVideoWidthKey : UIScreen.main.bounds.size.width,
3131
AVVideoHeightKey : UIScreen.main.bounds.size.height
3232
];
3333

34-
videoInput = AVAssetWriterInput (mediaType: AVMediaTypeVideo as String, outputSettings: videoOutputSettings)
34+
videoInput = AVAssetWriterInput (mediaType: AVMediaType.video, outputSettings: videoOutputSettings)
3535
videoInput.expectsMediaDataInRealTime = true
3636
assetWriter.add(videoInput)
3737
// RPScreenRecorder.shared().
@@ -42,13 +42,13 @@ import AVKit
4242

4343
if CMSampleBufferDataIsReady(sample)
4444
{
45-
if self.assetWriter.status == AVAssetWriterStatus.unknown
45+
if self.assetWriter.status == AVAssetWriter.Status.unknown
4646
{
4747
self.assetWriter.startWriting()
4848
self.assetWriter.startSession(atSourceTime: CMSampleBufferGetPresentationTimeStamp(sample))
4949
}
5050

51-
if self.assetWriter.status == AVAssetWriterStatus.failed {
51+
if self.assetWriter.status == AVAssetWriter.Status.failed {
5252
print("Error occured, status = \(self.assetWriter.status.rawValue), \(self.assetWriter.error!.localizedDescription) \(String(describing: self.assetWriter.error))")
5353
return
5454
}

ios/ScreenRecord/WindowUtil.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protocol Overlayable
1717
class WindowUtil: Overlayable
1818
{
1919
var overlayWindow = UIWindow(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 30))
20-
var stopButton = UIButton(type: UIButtonType.custom)
20+
var stopButton = UIButton(type: UIButton.ButtonType.custom)
2121
var stopButtonColor = UIColor(red:0.30, green:0.67, blue:0.99, alpha:1.00)
2222
var onStopClick:(() -> ())?
2323

@@ -29,7 +29,7 @@ class WindowUtil: Overlayable
2929
func initViews()
3030
{
3131
overlayWindow = UIWindow(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 30))
32-
stopButton = UIButton(type: UIButtonType.custom)
32+
stopButton = UIButton(type: UIButton.ButtonType.custom)
3333
}
3434

3535
func hide()
@@ -55,13 +55,13 @@ class WindowUtil: Overlayable
5555
stopButton.setTitle("Stop Recording", for: .normal)
5656
stopButton.titleLabel?.font = UIFont.systemFont(ofSize: UIFont.smallSystemFontSize)
5757

58-
stopButton.addTarget(self, action: #selector(stopRecording), for: UIControlEvents.touchDown)
58+
stopButton.addTarget(self, action: #selector(stopRecording), for: UIControl.Event.touchDown)
5959

6060

6161

6262
stopButton.frame = overlayWindow.frame
6363
overlayWindow.addSubview(stopButton)
64-
overlayWindow.windowLevel = CGFloat.greatestFiniteMagnitude
64+
overlayWindow.windowLevel = UIWindow.Level(rawValue: CGFloat.greatestFiniteMagnitude)
6565

6666
}
6767

0 commit comments

Comments
 (0)