添加录制功能

This commit is contained in:
kai60
2020-10-18 16:55:30 +08:00
parent 3356311c86
commit 52c13cc416
21 changed files with 355 additions and 53 deletions
@@ -36,6 +36,7 @@ static const CGFloat ToastFade = 0.2;
@property(assign) unsigned int remoteRecordState;
//本app 需求模式 非摄像头模式
@property(nonatomic,strong) NSMutableArray*array;
@property(nonatomic,strong) NSString*recordType;
@property (nonatomic, strong)MydatePickerView *mydatepicView;
@end
@@ -46,8 +47,11 @@ static const CGFloat ToastFade = 0.2;
[super viewDidLoad];
// Do any additional setup after loading the view.
[self addTitleViewWithTitle:@"录制视频"];
self.recordType=[[DataCenter defaultDtacenter].cache stringForKey:@"recordType"];
if (self.recordType.length)
{
self.recordType=@"0";
}
[self creatUI];
// self.view.backgroundColor = RGB(242, 242, 242);
@@ -80,11 +84,20 @@ static const CGFloat ToastFade = 0.2;
BOOL connectDevice = [[GWP2PClient sharedClient] connectWithAccount:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2 sessionID1:model.sessionID sessionID2:model.sessionID2 customerIDs:nil];
if (connectDevice) {
[[GWP2PClient sharedClient] setDeviceRecordDefinition:GWP2PRecordDefinitionStandardDefinition withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
}];
}else{
NSLog(@"p2pConnect failure.失败,不能操作设备");
[self.view makeToast:@"p2pConnect failure.失败,不能操作设备,请重试"];
}
}
else
{
[[GWP2PClient sharedClient] setDeviceRecordDefinition:GWP2PRecordDefinitionStandardDefinition withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
}];
}
}
@@ -132,7 +145,7 @@ static const CGFloat ToastFade = 0.2;
TemperatureSetModel*model=[[TemperatureSetModel alloc]init];
model.title=@"即时录制";
model.temperatureLabel=@"";
model.status=[[DataCenter defaultDtacenter].cache stringForKey:@"NowRecord"];
model.status=self.recordType;;
cell.titleLabel.text=model.title;
cell.temperaturelabel.text=model.temperatureLabel;
@@ -140,7 +153,7 @@ static const CGFloat ToastFade = 0.2;
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateSelected];
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
cell.selected=[model.status isEqualToString:@"1"];
cell.temPSwitch.selected=[model.status isEqualToString:@"1"];
@@ -152,7 +165,7 @@ static const CGFloat ToastFade = 0.2;
TemperatureSetModel*model=[[TemperatureSetModel alloc]init];
model.title=@"定时录制";
model.temperatureLabel=[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecordTime"].length?[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecordTime"]:@"09:00-16:00";
model.status=[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecord"];
model.status=self.recordType;;
cell.titleLabel.text=model.title;
cell.temperaturelabel.text=model.temperatureLabel;
@@ -161,7 +174,7 @@ static const CGFloat ToastFade = 0.2;
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateSelected];
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
cell.selected=[model.status isEqualToString:@"1"];
cell.temPSwitch.selected=[model.status isEqualToString:@"2"];
@@ -257,20 +270,40 @@ static const CGFloat ToastFade = 0.2;
-(void)nowRecordBtnAction:(UIButton*)btn{
btn.selected=!btn.selected;
[[DataCenter defaultDtacenter].cache setString:[NSString stringWithFormat:@"%ld",btn.selected] forKey:@"NowRecord"];
;
if (btn.selected)
{
self.recordType=@"1";
[[DataCenter defaultDtacenter].cache setString:self.recordType forKey:@"recordType"];
[[GWP2PClient sharedClient] setDeviceRecordType:GWP2PRecordTypeManual withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
if (success)
{
[self.view makeToast:@"设置成功"];
}
else
{
[self.view makeToast:@"设置失败"];
}
}];
}else
{
self.recordType=@"0";
[[DataCenter defaultDtacenter].cache setString:self.recordType forKey:@"recordType"];
[[GWP2PClient sharedClient] setDeviceRecordType:GWP2PRecordTypeAlarm withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
NSLog(@"data=%@",dataDictionary);
}];
[[GWP2PClient sharedClient] setDevicePrerecordState:YES withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
}];
[[GWP2PClient sharedClient] setDeviceAlarmRecordTime:3 withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
}];
}
[self.tab reloadData];
}
@@ -281,19 +314,53 @@ static const CGFloat ToastFade = 0.2;
btn.selected=!btn.selected;
[[DataCenter defaultDtacenter].cache setString:[NSString stringWithFormat:@"%ld",btn.selected] forKey:@"schduleRecord"];
if (btn.selected) {
self.recordType=@"2";
[[DataCenter defaultDtacenter].cache setString:self.recordType forKey:@"recordType"];
[[GWP2PClient sharedClient] setDeviceRecordType:GWP2PRecordTypeSchedule withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
NSLog(@"data=%@",dataDictionary);
}];
NSString*time=[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecordTime"].length?[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecordTime"]:@"09:00-16:00";
NSString*start=[[time componentsSeparatedByString:@"-"] firstObject];
NSString*end=[[time componentsSeparatedByString:@"-"] lastObject];
NSString*startHour=[[start componentsSeparatedByString:@":"] firstObject];
NSString*startMin=[[start componentsSeparatedByString:@":"] lastObject];
NSString*endHour=[[end componentsSeparatedByString:@":"] firstObject];
NSString*endMin=[[end componentsSeparatedByString:@":"] lastObject];
[[GWP2PClient sharedClient] setDevicePlanedRecordTimeWithFromHour:startHour.integerValue fromMinute:startMin.integerValue toHour:endHour.integerValue toMinute:endMin.integerValue deviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
if (success)
{
[self.view makeToast:@"设置成功"];
}
else
{
[self.view makeToast:@"设置失败"];
}
}];
}else{
self.recordType=@"0";
[[DataCenter defaultDtacenter].cache setString:self.recordType forKey:@"recordType"];
[[GWP2PClient sharedClient] setDeviceRecordType:GWP2PRecordTypeAlarm withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
NSLog(@"data=%@",dataDictionary);
}];
[[GWP2PClient sharedClient] setDevicePrerecordState:YES withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
}];
[[GWP2PClient sharedClient] setDeviceAlarmRecordTime:3 withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
}];
}
[self.tab reloadData];
}