ByFileViewController.mm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // ByFileViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/14.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "ByFileViewController.h"
  9. #import "VideoFileConfig.h" //录像查询接口类
  10. #import "DownloadViewController.h" //录像下载
  11. #import "ItemTableviewCell.h"
  12. @interface ByFileViewController () <UITableViewDelegate, UITableViewDataSource, VideoFileConfigDelegate>
  13. {
  14. VideoFileConfig *config;
  15. UITableView *tableV;
  16. NSMutableArray *recordArray;
  17. }
  18. @end
  19. @implementation ByFileViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. //初始化tableview数据
  23. [self initDataSource];
  24. [self configSubView];
  25. [self getVideoFileConfig];
  26. }
  27. - (void)viewWillDisappear:(BOOL)animated{
  28. //有加载状态、则取消加载
  29. if ([SVProgressHUD isVisible]){
  30. [SVProgressHUD dismiss];
  31. }
  32. }
  33. #pragma mark - 按文件查询设备录像信息
  34. - (void)getVideoFileConfig {
  35. [SVProgressHUD showWithStatus:TS("")];
  36. if (config == nil) {
  37. config = [[VideoFileConfig alloc] init];
  38. config.delegate = self;
  39. }
  40. //调用按文件查询录像的接口,查询今天的设备录像,可以自己设置日期进行查询
  41. [config getDeviceVideoByFile:[NSDate date]];
  42. }
  43. #pragma mark 获取摄像机录像代理回调
  44. - (void)getVideoResult:(NSInteger)result {
  45. if (result >= 0) {
  46. [SVProgressHUD dismiss];
  47. recordArray =[config getVideoFileArray];
  48. //成功,刷新界面数据
  49. [self.tableV reloadData];
  50. }else{
  51. [MessageUI ShowErrorInt:(int)result];
  52. }
  53. }
  54. #pragma mark - tableView代理方法
  55. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  56. return recordArray.count;
  57. }
  58. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  59. ItemTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemTableviewCell"];
  60. if (!cell) {
  61. cell = [[ItemTableviewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ItemTableviewCell"];
  62. }
  63. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  64. RecordInfo *record = [recordArray objectAtIndex:indexPath.row];
  65. cell.textLabel.text = record.fileName;
  66. cell.textLabel.numberOfLines = 0;
  67. cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
  68. return cell;
  69. }
  70. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  71. //点击下载录像
  72. DownloadViewController *downloadVC = [[DownloadViewController alloc] init];
  73. [self.navigationController pushViewController:downloadVC animated:YES];
  74. RecordInfo *record = [recordArray objectAtIndex:indexPath.row];
  75. [downloadVC startDownloadRecord:record];
  76. }
  77. #pragma mark - 界面和数据初始化
  78. - (void)configSubView {
  79. [self.view addSubview:self.tableV];
  80. }
  81. - (UITableView *)tableV {
  82. if (!tableV) {
  83. tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight ) style:UITableViewStylePlain];
  84. tableV.delegate = self;
  85. tableV.dataSource = self;
  86. [tableV registerClass:[ItemTableviewCell class] forCellReuseIdentifier:@"ItemTableviewCell"];
  87. }
  88. return tableV;
  89. }
  90. #pragma mark - 界面和数据初始化
  91. - (void)initDataSource {
  92. recordArray = [[NSMutableArray alloc] initWithCapacity:0];
  93. }
  94. - (void)didReceiveMemoryWarning {
  95. [super didReceiveMemoryWarning];
  96. // Dispose of any resources that can be recreated.
  97. }
  98. @end