MKRWIFIDeviceManager.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //
  2. // MKRWIFIDeviceManager.h
  3. // MKRAVPlayer
  4. //
  5. // Created by yyqxiaoyin on 2019/4/16.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import "MKRUPnPDevice.h"
  9. #import "MKRM3UListModel.h"
  10. #import "MKRRadioResorce.h"
  11. #define _MKRWIFIDeviceManager [MKRWIFIDeviceManager shareManager]
  12. @protocol MKRWIFIDeviceManagerDelegate <NSObject>
  13. @optional
  14. /** 已经搜索到的设备数组发生改变 */
  15. - (void)currentDevicesChange:(NSArray <NSDictionary *> *)deviceArray;
  16. /** 搜索到新设备 */
  17. - (void)didSearchNewDevice:(NSDictionary *)newDecice;
  18. @end
  19. @interface MKRWIFIDeviceManager : NSObject
  20. + (instancetype)shareManager;
  21. @property (nonatomic, strong)NSString *userID;
  22. - (void)addDeviceManagerListener:(id<MKRWIFIDeviceManagerDelegate>)listener;
  23. - (void)removeDeviceManagerListener:(id<MKRWIFIDeviceManagerDelegate>)listener;
  24. /**
  25. * 初始化UPNP
  26. * @return UPNP初始化错误码 0为无错误 即初始化成功
  27. */
  28. - (NSInteger)startUpnp;
  29. /**
  30. * 搜索设备
  31. * @param searchTime 搜索时长
  32. * @param timeBlock 搜索回调 每秒在主线程回调一次
  33. */
  34. - (void)searchDeviceWithSearchTime:(int)searchTime
  35. timeBlock:(void(^)(NSInteger time,NSArray <NSDictionary *>*devices))timeBlock;
  36. /**
  37. * 生成m3u列表
  38. * @param m3uListModel m3u列表模型
  39. */
  40. - (void)setM3UList:(MKRM3UListModel *)m3uListModel;
  41. /**
  42. * 设置设备单首播放的资源
  43. * @param song 需要播放的资源
  44. * @param device 需要设置的设备
  45. * @param userID 用户ID
  46. */
  47. - (void)setAVTransportURIWithSong:(id <MKRRadioResorce>)song
  48. device:(id <MKRUPnPDevice>)device
  49. userID:(NSString *)userID;
  50. /**
  51. * 播放
  52. * @param device 设备
  53. */
  54. - (void)playWithDevice:(id <MKRUPnPDevice>)device;
  55. /**
  56. * 播放channelNO频道从第index开始
  57. * 在播放之前 如果是临时频道(频道号>= 12) 需要先生成M3U列表
  58. * 如是正式频道(频道号 0~11) 可选生成M3U
  59. * @param channelNO 频道号
  60. * @param index 需要播放的下标
  61. * @param device 播放的设备
  62. * @param userID 用户ID
  63. */
  64. - (void)playSongWithChannelNO:(NSInteger)channelNO
  65. index:(NSInteger)index
  66. device:(id <MKRUPnPDevice>)device
  67. userID:(NSString *)userID;
  68. /**
  69. * 播放channelNO频道 从第0首开始
  70. * @param channelNO 频道号
  71. * @param device 需要播放的设备
  72. * @param userID 用户ID
  73. */
  74. - (void)playSongWithChannelNO:(NSInteger)channelNO
  75. device:(id <MKRUPnPDevice>)device
  76. userID:(NSString *)userID;
  77. /**
  78. * 暂停
  79. * @param device 设备
  80. */
  81. - (void)pauseWithDevice:(id <MKRUPnPDevice>)device;
  82. /**
  83. * 下一首
  84. * @param device 设备
  85. */
  86. - (void)nextWithDevice:(id <MKRUPnPDevice>)device;
  87. /**
  88. * 上一首
  89. * @param device 设备
  90. */
  91. - (void)previousWithDevice:(id <MKRUPnPDevice>)device;
  92. /**
  93. * 停止
  94. * @param device 设备
  95. */
  96. - (void)stopWithDevice:(id <MKRUPnPDevice>)device;
  97. /**
  98. * 设置音量
  99. * @param volume 音量值 1~100
  100. * @param device 设备
  101. */
  102. - (void)setVolume:(int)volume device:(id <MKRUPnPDevice>)device;
  103. /**
  104. * 快进到timeInterval 的进度
  105. * @param timeInterval 快进/快退目标秒数
  106. * @param device 需要快进的设备
  107. */
  108. - (void)seekToTimeInterval:(NSInteger)timeInterval device:(id <MKRUPnPDevice>)device;
  109. /**
  110. * 清空设备中的其中一个频道
  111. * @param channelNO 频道号
  112. * @param device 设备
  113. */
  114. - (void)clearChannelWithChannelNO:(NSString *)channelNO device:(id <MKRUPnPDevice>)device;
  115. - (id <MKRRadioResorce>)getPlayingStatusWithDevice:(id <MKRUPnPDevice>)device;
  116. @end