MKRViewController.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // MKRViewController.m
  3. // MKRRadioManager
  4. //
  5. // Created by yyqxiaoyin on 04/15/2019.
  6. // Copyright (c) 2019 yyqxiaoyin. All rights reserved.
  7. //
  8. #import "MKRViewController.h"
  9. #import "MKRPlayControlViewController.h"
  10. #import <MKRRadioManager/MKRAVPlayer.h>
  11. #import <YYCategory/NSString+Utilities.h>
  12. @interface MKRViewController ()
  13. @property (nonatomic, strong)UITableView *tableView;
  14. @property (nonatomic, strong)NSMutableArray *dataSource;
  15. @property (nonatomic, strong) MKRAVPlayer *player;
  16. @end
  17. @implementation MKRViewController
  18. - (IBAction)refresh:(UIBarButtonItem *)sender {
  19. [self.dataSource removeAllObjects];
  20. [self searchDevice];
  21. }
  22. - (void)searchDevice{
  23. [_MKRWIFIDeviceManager searchDeviceWithSearchTime:20 timeBlock:^(NSInteger time) {
  24. [self.tableView reloadData];
  25. }];
  26. }
  27. - (void)viewDidLoad
  28. {
  29. [super viewDidLoad];
  30. }
  31. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  32. return self.dataSource.count;
  33. }
  34. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  35. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  36. MKRUPnPDevice *device = self.dataSource[indexPath.row];
  37. cell.textLabel.text = device.deviceName;
  38. return cell;
  39. }
  40. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  41. MKRPlayControlViewController *vc = [[MKRPlayControlViewController alloc] initWithDevice:self.dataSource[indexPath.row]];
  42. [self.navigationController pushViewController:vc animated:YES];
  43. }
  44. - (NSMutableArray *)dataSource {
  45. if (!_dataSource) {
  46. _dataSource = [NSMutableArray array];
  47. }
  48. return _dataSource;
  49. }
  50. @end