|
@@ -10,6 +10,7 @@
|
|
|
#import "UIDevice+MKRRadioManagerAdd.h"
|
|
|
#import <pthread.h>
|
|
|
#import <libAS-Control/ASControlTools.h>
|
|
|
+#import <libAS-Control/NSDictionary+MKRXml.h>
|
|
|
|
|
|
static inline void wd_main_queue(void (^block)(void)){
|
|
|
if (pthread_main_np()) {
|
|
@@ -448,51 +449,34 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
}
|
|
|
|
|
|
- (id <MKRRadioResorce>)getPlayingStatusWithDevice:(id <MKRUPnPDevice>)device {
|
|
|
-
|
|
|
wd_playControl_queue(^{
|
|
|
- NSString *string = [[ASControlTools sharedInstanceUPNP] libupnp_getPlayInfo:device.avTransportUrl];
|
|
|
- NSLog(@"新的获取播放信息\n%@",string);
|
|
|
+ NSDictionary *originDic = [[ASControlTools sharedInstanceUPNP] libupnp_getPlayInfo:device.avTransportUrl];
|
|
|
+ NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:originDic];
|
|
|
+ NSDictionary *metaDataDic = [[NSDictionary mkr_dictionaryWithXML:dic[@"TrackMetaData"]] objectForKey:@"item"] ? : @{};
|
|
|
+ [dic setObject:metaDataDic forKey:@"TrackMetaData"];
|
|
|
+ @synchronized (self.currentResource) {
|
|
|
+ self.currentResource.songName = dic[@"upnp:songName"];
|
|
|
+ self.currentResource.songArtist = dic[@"upnp:songPlayer"];
|
|
|
+ self.currentResource.songAlbumCover = dic[@"upnp:songThumb"];
|
|
|
+ self.currentResource.songID = [dic[@"upnp:songInfoID"] integerValue];
|
|
|
+ self.currentResource.songFrom = [dic[@"upnp:songPlatform"] integerValue];
|
|
|
+ self.currentResource.resourceStatus.totalTime = [dic[@"upnp:songDuration"] integerValue];
|
|
|
+ self.currentResource.sourceType = [dic[@"upnp:songType"] integerValue];
|
|
|
+ self.currentResource.songAlbumID = dic[@"upnp:songAlbumID"];
|
|
|
+ NSString *channelString = dic[@"upnp:songFlag"];
|
|
|
+ NSInteger songChannel = 0;
|
|
|
+ if ([channelString containsString:@"-"]) {
|
|
|
+ NSArray *channelStringArr = [channelString componentsSeparatedByString:@"-"];
|
|
|
+ songChannel = [[channelStringArr firstObject] integerValue];
|
|
|
+ }else{
|
|
|
+ songChannel = [channelString integerValue];
|
|
|
+ }
|
|
|
+ self.currentResource.songChannel = songChannel;
|
|
|
+ NSString *songChannelUid = [NSString stringWithFormat:@"%@-%@-%zd",self.userID,device.deviceUUID,songChannel];
|
|
|
+ self.currentResource.songChannelUid = songChannelUid;
|
|
|
+ self.currentResource.songFlag = [NSString stringWithFormat:@"%@_%@_%@",songChannelUid,dic[@"upnp:songInfoID"],[dic[@"upnp:songPlatform"] integerValue]];
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
-// wd_playControl_queue(^{
|
|
|
-// NSArray *dmrPositionInfo = [[ASControlTools sharedInstanceUPNP] libupnp_GetPositionInfo:device.avTransportUrl];
|
|
|
-// if (dmrPositionInfo.count < 16) {
|
|
|
-// //执行检查设备是否掉线操作
|
|
|
-// return ;
|
|
|
-// }
|
|
|
-//// MKRRadioResorce *resource = [[MKRRadioResorce alloc] init];
|
|
|
-// @synchronized (_currentResource) {
|
|
|
-// self.currentResource.songName = dmrPositionInfo[2];
|
|
|
-// self.currentResource.songArtist = dmrPositionInfo[3];
|
|
|
-// self.currentResource.songAlbumCover = dmrPositionInfo[5];
|
|
|
-// self.currentResource.songUrl = dmrPositionInfo[7];
|
|
|
-// self.currentResource.songID = [dmrPositionInfo[16] integerValue];
|
|
|
-// NSString *songFrom = dmrPositionInfo[17];
|
|
|
-// if ([songFrom containsString:@"//"]) {
|
|
|
-// NSArray *arr = [songFrom componentsSeparatedByString:@"//"];
|
|
|
-// if (arr.count > 1) {
|
|
|
-// songFrom = arr[1];
|
|
|
-// }
|
|
|
-// }
|
|
|
-// self.currentResource.songFrom = (MKRSourcePlatform)[songFrom integerValue];
|
|
|
-// NSString *channelString = dmrPositionInfo[8];
|
|
|
-// if (![channelString containsString:@"Unknown:TrackMetaData Incomplete"]) {
|
|
|
-// if ([channelString containsString:@"CHANNEL_UPDATE_"]) {
|
|
|
-// self.currentResource.songChannel = [[channelString componentsSeparatedByString:@"CHANNEL_UPDATE_"].lastObject integerValue];
|
|
|
-// } else {
|
|
|
-// self.currentResource.songChannel = [channelString integerValue];
|
|
|
-// }
|
|
|
-// }
|
|
|
-// // resource.songLength = [self secondsFromTimeString:dmrPositionInfo[1]];
|
|
|
-// // MKRPlayResourceStatus *status = [MKRPlayResourceStatus new];
|
|
|
-// // status.currentTime = [[self secondsFromTimeString:dmrPositionInfo[10]] integerValue];
|
|
|
-// // status.totalTime = [oneSong.songLength integerValue];
|
|
|
-// NSString *songChannelUid = [NSString stringWithFormat:@"%@-%@-%zd",self.userID,device.deviceUUID,self.currentResource.songChannel];
|
|
|
-// self.currentResource.songChannelUid = songChannelUid;
|
|
|
-// self.currentResource.songFlag = [NSString stringWithFormat:@"%@_%zd_%@",songChannelUid,[dmrPositionInfo[16] integerValue],songFrom];
|
|
|
-// }
|
|
|
-// });
|
|
|
-
|
|
|
return self.currentResource;
|
|
|
}
|
|
|
|