123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- //
- // MKRPlayControlViewController.m
- // MKRRadioManager_Example
- //
- // Created by yyqxiaoyin on 2019/4/17.
- // Copyright © 2019 yyqxiaoyin. All rights reserved.
- //
- #import "MKRPlayControlViewController.h"
- @interface MKRPlayControlViewController ()<UITableViewDataSource,UITableViewDelegate>
- @property (nonatomic, strong) MKRUPnPDevice *device;
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) NSArray *dataSource;
- @end
- @implementation MKRPlayControlViewController
- - (instancetype)initWithDevice:(MKRUPnPDevice *)device{
- if (self = [super init]) {
- // [[MKRRadioControlMaster shareMaster] changeCurrentDevice:device];
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = [UIColor whiteColor];
- self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
- [self.view addSubview:self.tableView];
-
- self.dataSource = @[
- @{@"播放":@"play"},
- @{@"播放频道":@"playChannel:"},
- @{@"暂停":@"pause"},
- @{@"上一曲":@"previous"},
- @{@"下一曲":@"next"},
- @{@"停止":@"stop"},
- @{@"音量+":@"volumePlus"},
- @{@"音量-":@"volumeMins"},
- ];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- NSDictionary *dic = self.dataSource[indexPath.row];
- cell.textLabel.text = [dic.allKeys firstObject];
- return cell;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.dataSource.count;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- NSDictionary *dic = self.dataSource[indexPath.row];
- NSString *selString = [dic.allValues firstObject];
- SEL sel = NSSelectorFromString(selString);
- if ([selString containsString:@":"]) {
- int x = arc4random() % (11 - 0 + 1) + 0;
- [self performSelector:sel withObject:@(x).stringValue afterDelay:0];
- }else{
- [self performSelector:sel withObject:nil afterDelay:0];
- }
- }
- - (void)play{
- // [_MKRRadioControlMaster play];
- // [_MKRWIFIDeviceManager playWithDevice:self.device];
- }
- - (void)playChannel:(NSString *)channel{
- NSLog(@"播放频道:%@",channel);
- // [_MKRRadioControlMaster playSongWithChannelNO:channel userID:@""];
- // [_MKRWIFIDeviceManager playSongWithChannelNO:[channel integerValue]
- // index:0
- // device:self.device
- // userID:@""];
- }
- - (void)pause{
- // [_MKRRadioControlMaster pause];
- // [_MKRWIFIDeviceManager pauseWithDevice:self.device];
- }
- - (void)previous{
- // [_MKRRadioControlMaster previous];
- // [_MKRWIFIDeviceManager previousWithDevice:self.device];
- }
- - (void)next{
- // [_MKRRadioControlMaster next];
- // [_MKRWIFIDeviceManager nextWithDevice:self.device];
- }
- - (void)stop{
- // [_MKRRadioControlMaster stop];
- // [_MKRWIFIDeviceManager stopWithDevice:self.device];
- }
- - (void)volumePlus{
- // [_MKRRadioControlMaster setVolume:80];
- // [_MKRWIFIDeviceManager setVolume:80 device:self.device];
- }
- - (void)volumeMins{
- // [_MKRRadioControlMaster setVolume:20];
- // [_MKRWIFIDeviceManager setVolume:20 device:self.device];
- }
- @end
|