From bebdc20c72f8fea3c7c2972ee5683c417c5d3df6 Mon Sep 17 00:00:00 2001 From: tonychan Date: Mon, 28 Feb 2022 17:17:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E4=B8=8B=E8=BD=BD=20UIDemo?= =?UTF-8?q?=20=E4=BA=8B=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tapd: http://tapd.oa.com/NEW_IOT/prong/stories/view/1020393192870647767 Change-Id: I24624fad7fd235bf5af104f2f6099c9cb1263976 --- .../Login/res_download.imageset/Contents.json | 21 +++++++++++ .../res_download.imageset/res_download.png | Bin 0 -> 208 bytes .../Controller/TIoTDemoLocalDayCustomCell.h | 6 ++++ .../Controller/TIoTDemoLocalDayCustomCell.m | 33 ++++++++++++++---- .../Controller/TIoTDemoLocalRecordVC.m | 27 +++++++------- Source/SDK/LinkVideo/TIoTCoreXP2PBridge.h | 2 ++ 6 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 Source/LinkSDKDemo/Assets.xcassets/Login/res_download.imageset/Contents.json create mode 100644 Source/LinkSDKDemo/Assets.xcassets/Login/res_download.imageset/res_download.png diff --git a/Source/LinkSDKDemo/Assets.xcassets/Login/res_download.imageset/Contents.json b/Source/LinkSDKDemo/Assets.xcassets/Login/res_download.imageset/Contents.json new file mode 100644 index 000000000..50fa13577 --- /dev/null +++ b/Source/LinkSDKDemo/Assets.xcassets/Login/res_download.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "res_download.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Source/LinkSDKDemo/Assets.xcassets/Login/res_download.imageset/res_download.png b/Source/LinkSDKDemo/Assets.xcassets/Login/res_download.imageset/res_download.png new file mode 100644 index 0000000000000000000000000000000000000000..410265d46c94ab9cca7a6f97650393253c2f41ef GIT binary patch literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC&H|6fVg?3oVGw3ym^DWNDA?rb z;uw%}*_4)6GEwUOEJ$h2qb-yNR47ZPOn(QQ}xQb3@W-{mp$#UBnP zb^^M8*>4>>arN>k!7S5z%1&#KN4u@KUeV3*Rc^nr)8b?AI|4ixh05(0nwa;;$K}?? zc%@7I_1zlA|1=lf`SEZEp99m~pWBojegN$+DrU-gaPY?Ahx_w^JO)o!KbLh*2~7Zm Cnosor literal 0 HcmV?d00001 diff --git a/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalDayCustomCell.h b/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalDayCustomCell.h index de406d94f..2a565b450 100644 --- a/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalDayCustomCell.h +++ b/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalDayCustomCell.h @@ -9,8 +9,14 @@ NS_ASSUME_NONNULL_BEGIN +@protocol TIoTDemoLocalDayCustomCellDelegate +- (void)downLoadResWithModel:(TIoTDemoLocalFileModel *)model; +@end + + @interface TIoTDemoLocalDayCustomCell : UITableViewCell @property (nonatomic, strong) TIoTDemoLocalFileModel *model; +@property (nonatomic, weak)id delegate; @end NS_ASSUME_NONNULL_END diff --git a/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalDayCustomCell.m b/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalDayCustomCell.m index cae52700c..77e3731ad 100644 --- a/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalDayCustomCell.m +++ b/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalDayCustomCell.m @@ -12,7 +12,7 @@ @interface TIoTDemoLocalDayCustomCell () @property (nonatomic, strong) UIView *contentCustomView; @property (nonatomic, strong) UILabel *eventTimeabel; @property (nonatomic, strong) UILabel *eventDescribe; -@property (nonatomic, strong) UIImageView *eventThumb; +@property (nonatomic, strong) UIButton *eventThumb; @property (nonatomic, strong) UIImageView *thumbActionImage; @end @@ -38,7 +38,7 @@ - (void)setupCellViews { self.contentView.backgroundColor = [UIColor colorWithHexString:KActionSheetBackgroundColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; - self.contentCustomView = [[UILabel alloc]init]; + self.contentCustomView = [[UIView alloc]init]; self.contentCustomView.backgroundColor = [UIColor whiteColor] ; [self.contentView addSubview:self.contentCustomView]; [self.contentCustomView mas_makeConstraints:^(MASConstraintMaker *make) { @@ -65,7 +65,17 @@ - (void)setupCellViews { make.right.equalTo(self.contentCustomView.mas_right).offset(2*kWidthPadding+100); }]; - self.eventThumb = [[UIImageView alloc]init]; + self.eventThumb = [[UIButton alloc]init]; + [self.eventThumb setBackgroundImage:[UIImage imageNamed:@"res_download"] forState:UIControlStateNormal]; + [self.eventThumb addTarget:self action:@selector(downLoadCell) forControlEvents:UIControlEventTouchUpInside]; + [self.contentCustomView addSubview:self.eventThumb]; + [self.eventThumb mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.equalTo(self.contentCustomView); + make.right.equalTo(self.contentCustomView.mas_right).offset(-kWidthPadding); + make.width.height.mas_equalTo(32); + }]; + + /*self.eventThumb = [[UIImageView alloc]init]; self.eventThumb.backgroundColor = [UIColor blackColor]; [self.contentCustomView addSubview:self.eventThumb]; [self.eventThumb mas_makeConstraints:^(MASConstraintMaker *make) { @@ -81,19 +91,28 @@ - (void)setupCellViews { [self.thumbActionImage mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self.eventThumb); make.width.height.mas_equalTo(32); - }]; + }];*/ } +- (void)downLoadCell { + if ([self.delegate respondsToSelector:@selector(downLoadResWithModel:)]) { + [self.delegate downLoadResWithModel:_model]; + } +} + - (void)setModel:(TIoTDemoLocalFileModel *)model { _model = model; - NSString *timeString = [NSString convertTimestampToTime:model.start_time?:@"" byDateFormat:@"YYYY-MM-dd HH:mm:ss"]; + /*NSString *timeString = [NSString convertTimestampToTime:model.start_time?:@"" byDateFormat:@"YYYY-MM-dd HH:mm:ss"]; NSString *dayTime = [timeString componentsSeparatedByString:@" "].lastObject; NSString *hourString = [dayTime componentsSeparatedByString:@":"].firstObject; NSString *minuteString = [dayTime componentsSeparatedByString:@":"][1]; self.eventTimeabel.text = [NSString stringWithFormat:@"%@:%@",hourString,minuteString]; - self.eventDescribe.text = model.file_name?:@""; - [self.eventThumb setImageWithURLStr:model.file_size?:@"" placeHolder:@""]; + self.eventDescribe.text = model.file_name?:@"";*/ + + NSString *startString = [NSString convertTimestampToTime:model.start_time?:@"" byDateFormat:@"HH:mm:ss"]; + NSString *endString = [NSString convertTimestampToTime:model.end_time?:@"" byDateFormat:@"HH:mm:ss"]; + self.eventTimeabel.text = [NSString stringWithFormat:@"%@ - %@",startString,endString]; } - (void)awakeFromNib { diff --git a/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalRecordVC.m b/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalRecordVC.m index b968de305..8c085cfd3 100644 --- a/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalRecordVC.m +++ b/Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalRecordVC.m @@ -39,7 +39,7 @@ static NSString *const kPlayback = @"ipc.flv?action=playback"; -@interface TIoTDemoLocalRecordVC () +@interface TIoTDemoLocalRecordVC () @property (nonatomic, assign) CGRect screenRect; @property (nonatomic, strong) NSString *dayDateString; //选择天日期 @property (nonatomic, strong) UIImageView *imageView; @@ -436,7 +436,7 @@ - (void)setupUIViews { self.tableView.backgroundColor = [UIColor colorWithHexString:KActionSheetBackgroundColor]; self.tableView.delegate = self; self.tableView.dataSource = self; - self.tableView.rowHeight = 84; + self.tableView.rowHeight = 66; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [self.tableView registerClass:[TIoTDemoLocalDayCustomCell class] forCellReuseIdentifier:kPlaybackLocalCellID]; [self.view addSubview:self.tableView]; @@ -727,6 +727,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { TIoTDemoLocalDayCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:kPlaybackLocalCellID forIndexPath:indexPath]; + cell.delegate = self; cell.model = self.dataArray[indexPath.row]; return cell; } @@ -739,14 +740,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath self.isPause = NO; TIoTDemoLocalFileModel *selectedModel = self.dataArray[indexPath.row]; -// [self setVieoPlayerStartPlayStartTime:selectedModel.start_time endTime:selectedModel.end_time]; - [self downLoadFile:selectedModel]; + [self setVieoPlayerStartPlayStartTime:selectedModel.start_time endTime:selectedModel.end_time]; +// [self downLoadResWithModel:selectedModel]; } -- (void)downLoadFile:(TIoTDemoLocalFileModel *)filemodel { -// [TIoTCoreXP2PBridge sharedInstance].logEnable = NO; +#pragma mark - TIoTDemoLocalDayCustomCellDelegate +- (void)downLoadResWithModel:(TIoTDemoLocalFileModel *)model { - NSString *logFile = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:filemodel.file_name]; + [TIoTCoreXP2PBridge sharedInstance].logEnable = NO; + [MBProgressHUD showLodingNoneEnabledInView:self.view withMessage:@"下载资源中"]; + + NSString *logFile = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:model.file_name]; [[NSFileManager defaultManager] removeItemAtPath:logFile error:nil]; [[NSFileManager defaultManager] createFileAtPath:logFile contents:nil attributes:nil]; _saveDownloadFile = [NSFileHandle fileHandleForWritingAtPath:logFile]; @@ -754,13 +758,7 @@ - (void)downLoadFile:(TIoTDemoLocalFileModel *)filemodel { //设置代理,接受《下载的视频数据》和《下载完成事件》代理 [TIoTCoreXP2PBridge sharedInstance].delegate = self; - UILabel *fileTip = [[UILabel alloc] initWithFrame:self.imageView.bounds]; - fileTip.text = @"数据帧写文件中..."; - fileTip.textAlignment = NSTextAlignmentCenter; - fileTip.textColor = [UIColor whiteColor]; - [self.imageView addSubview:fileTip]; - - NSString *fileurl = [NSString stringWithFormat:@"action=download&channel=0&file_name=%@&offset=%d",filemodel.file_name ,0]; + NSString *fileurl = [NSString stringWithFormat:@"action=download&channel=0&file_name=%@&offset=%d",model.file_name ,0]; [[TIoTCoreXP2PBridge sharedInstance] startAvRecvService:self.deviceName?:@"" cmd:fileurl]; } @@ -779,6 +777,7 @@ - (void)reviceEventMsgWithID:(NSString *)dev_name eventType:(XP2PType)eventType NSLog(@"----videodataFFFFFFFFFinsi===%d",eventType); [[TIoTCoreXP2PBridge sharedInstance] stopAvRecvService:self.deviceName?:@""]; + [MBProgressHUD dismissInView:self.view]; [MBProgressHUD showError:@"文件已下载完成"]; } } diff --git a/Source/SDK/LinkVideo/TIoTCoreXP2PBridge.h b/Source/SDK/LinkVideo/TIoTCoreXP2PBridge.h index 5b02d7850..2586928c1 100644 --- a/Source/SDK/LinkVideo/TIoTCoreXP2PBridge.h +++ b/Source/SDK/LinkVideo/TIoTCoreXP2PBridge.h @@ -18,6 +18,8 @@ extern NSNotificationName const TIoTCoreXP2PBridgeNotificationStreamEnd; @protocol TIoTCoreXP2PBridgeDelegate /* + * ⚠️⚠️⚠️ 谨慎!!! === 此接口切勿执行耗时操作,耗时操作请切换线程,切勿卡住当前线程 + * * 裸流接口使用方式: * 通过 startAvRecvService 和 stopAvRecvService 接口,可以启动和停止裸流传输 * 客户端拉取到的裸流数据对应 data 参数