-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8570196
commit c3c2bf8
Showing
8 changed files
with
196 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
JLScreenRecordDemo/JLScreenRecordDemo/JLScreenRecordKit/JLRecorderManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// JLRecorderManager.h | ||
// JLScreenRecordDemo | ||
// | ||
// Created by 孙金亮 on 2018/2/2. | ||
// Copyright © 2018年 hiscene. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
typedef void (^VideoCompletionBlock)(NSString * path); | ||
|
||
@interface JLRecorderManager : NSObject | ||
@property (nonatomic, readonly) BOOL isRecording; | ||
|
||
@property(nonatomic,assign)NSInteger maxRecordTime;//最大录屏时间 defalut 60s | ||
@property(nonatomic,assign)NSInteger minRecordTime;//最大录屏时间 defalut 60s | ||
@property (strong, nonatomic) NSURL *videoURL;//视频文件目标目标地址,不设置也可以 | ||
@property(nonatomic,assign)int top_edge; //录屏范围上边距 | ||
@property(nonatomic,assign)int buttom_edge;//录屏范围下边距 | ||
|
||
+ (instancetype)sharedInstance; | ||
- (BOOL)startRecording; | ||
- (void)stopRecordingWithCompletion:(VideoCompletionBlock)completionBlock; | ||
- (void)clear; //单例类必须主动清理 | ||
- (void)clearFile;//清理录制缓存文件; | ||
|
||
@end |
109 changes: 109 additions & 0 deletions
109
JLScreenRecordDemo/JLScreenRecordDemo/JLScreenRecordKit/JLRecorderManager.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// | ||
// JLRecorderManager.m | ||
// JLScreenRecordDemo | ||
// | ||
// Created by 孙金亮 on 2018/2/2. | ||
// Copyright © 2018年 hiscene. All rights reserved. | ||
// | ||
|
||
#import "JLRecorderManager.h" | ||
#import "JLAudioRecord.h" | ||
#import "JLScreenRecorder.h" | ||
#import "JLCaptureUtilities.h" | ||
|
||
|
||
@interface JLRecorderManager() | ||
|
||
@property(nonatomic,strong) JLAudioRecord * audioRecord; | ||
@property(nonatomic,copy) VideoCompletionBlock completionBlock; | ||
@property(nonatomic,strong)JLScreenRecorder * screenRecord; | ||
|
||
@end | ||
|
||
@implementation JLRecorderManager | ||
|
||
|
||
|
||
#pragma mark - initializers | ||
static dispatch_once_t once; | ||
static JLRecorderManager * sharedInstance; | ||
+ (instancetype)sharedInstance { | ||
|
||
|
||
dispatch_once(&once, ^{ | ||
sharedInstance = [[self alloc] init]; | ||
}); | ||
return sharedInstance; | ||
} | ||
- (void)clear{ | ||
once = 0; | ||
sharedInstance = nil; | ||
|
||
} | ||
|
||
- (void)dealloc{ | ||
|
||
[self clearFile]; | ||
|
||
} | ||
- (instancetype)init | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
|
||
self.screenRecord = [[JLScreenRecorder alloc]init]; | ||
self.audioRecord = [[JLAudioRecord alloc]init]; | ||
[self.audioRecord prepareRecord]; | ||
} | ||
|
||
return self; | ||
} | ||
- (void)clearFile{ | ||
[self.screenRecord clearFile]; | ||
[self.audioRecord clearAudioFile]; | ||
|
||
} | ||
- (BOOL)startRecording | ||
{ | ||
|
||
[self.audioRecord beginRecord]; | ||
|
||
return [self.screenRecord startRecording]; | ||
|
||
|
||
} | ||
|
||
- (void)stopRecordingWithCompletion:(VideoCompletionBlock)completionBlock; | ||
{ | ||
self.completionBlock = completionBlock; | ||
[self.audioRecord endRecord]; | ||
__weak typeof(self) weakSelf = self; | ||
[self.screenRecord stopRecordingWithCompletion:^(NSURL *vedioUrl) { | ||
|
||
[JLCaptureUtilities mergeVideo:vedioUrl andAudio:weakSelf.audioRecord.recordFilePath andTarget:weakSelf andAction:@selector(mergedidFinish:WithError:)]; | ||
[weakSelf.screenRecord clearFile]; | ||
|
||
}]; | ||
|
||
} | ||
|
||
- (void)mergedidFinish:(NSString *)videoPath WithError:(NSError *)error | ||
{ | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
if (self.completionBlock) self.completionBlock(videoPath); | ||
}); | ||
} | ||
|
||
- (void)setTop_edge:(int)top_edge{ | ||
_top_edge = top_edge; | ||
self.screenRecord.top_edge = top_edge; | ||
|
||
|
||
} | ||
-(void)setButtom_edge:(int)buttom_edge{ | ||
_buttom_edge = buttom_edge; | ||
self.screenRecord.buttom_edge = buttom_edge; | ||
|
||
|
||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.