|
@@ -503,26 +503,30 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
|
|
|
- (id <MKRRadioResorce>)getPlayingStatusWithDevice:(id <MKRUPnPDevice>)device {
|
|
|
wd_playControl_queue(^{
|
|
|
- NSDictionary *originDic = [[ASControlTools sharedInstanceUPNP] libupnp_getPlayInfo:device.avTransportUrl];
|
|
|
- if (!originDic || !originDic.allKeys.count) {
|
|
|
+ NSDictionary *resultDic = [[ASControlTools sharedInstanceUPNP] libupnp_getPlayInfo:device.avTransportUrl];
|
|
|
+ if (!resultDic || !resultDic.allKeys.count) {
|
|
|
return ;
|
|
|
}
|
|
|
- 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[@"TrackMetaData"][@"upnp:songName"];
|
|
|
- self.currentResource.songArtist = dic[@"TrackMetaData"][@"upnp:songPlayer"];
|
|
|
- self.currentResource.songAlbumCover = dic[@"TrackMetaData"][@"upnp:songThumb"];
|
|
|
- self.currentResource.songID = [dic[@"TrackMetaData"][@"upnp:songInfoID"] integerValue];
|
|
|
- self.currentResource.songFrom = [dic[@"TrackMetaData"][@"upnp:songPlatform"] integerValue];
|
|
|
- self.currentResource.resourceStatus.totalTime = [NSString secondsFromHHmmssFormatStrig:dic[@"TrackDuration"]];
|
|
|
- self.currentResource.resourceStatus.currentTime = [NSString secondsFromHHmmssFormatStrig:dic[@"RelTime"]];
|
|
|
- self.currentResource.resourceStatus.playState = [self.currentResource.resourceStatus updatePlayState:dic[@"CurrentTransportState"]];
|
|
|
- NSInteger sourceType = [self convertSorceTypeWithAudioType:[dic[@"TrackMetaData"][@"upnp:songType"] integerValue]];
|
|
|
+ self.currentResource.songName = resultDic[@"TrackMetaData"][@"upnp:songName"];
|
|
|
+ self.currentResource.songArtist = resultDic[@"TrackMetaData"][@"upnp:songPlayer"];
|
|
|
+ self.currentResource.songAlbumCover = resultDic[@"TrackMetaData"][@"upnp:songThumb"];
|
|
|
+ self.currentResource.songID = [resultDic[@"TrackMetaData"][@"upnp:songInfoID"] integerValue];
|
|
|
+ id songFrom = resultDic[@"TrackMetaData"][@"upnp:songPlatform"];
|
|
|
+ if (![songFrom isKindOfClass:NSString.class]) {
|
|
|
+ songFrom = @"0";
|
|
|
+ }
|
|
|
+ self.currentResource.songFrom = [songFrom integerValue];
|
|
|
+ self.currentResource.resourceStatus.totalTime = [NSString secondsFromHHmmssFormatStrig:resultDic[@"TrackDuration"]];
|
|
|
+ self.currentResource.resourceStatus.currentTime = [NSString secondsFromHHmmssFormatStrig:resultDic[@"RelTime"]];
|
|
|
+ self.currentResource.resourceStatus.playState = [self.currentResource.resourceStatus updatePlayState:resultDic[@"CurrentTransportState"]];
|
|
|
+ NSInteger sourceType = [MKRM3UListModel convertSorceTypeWithAudioType:[resultDic[@"TrackMetaData"][@"upnp:songType"] integerValue]];
|
|
|
self.currentResource.sourceType = sourceType;
|
|
|
- self.currentResource.songAlbumID = dic[@"TrackMetaData"][@"upnp:songAlbumID"];
|
|
|
- NSString *channelString = dic[@"TrackMetaData"][@"upnp:songFlag"];
|
|
|
+ id songAlbumID = resultDic[@"TrackMetaData"][@"upnp:songAlbumID"];
|
|
|
+ if ([songAlbumID isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.songAlbumID = resultDic[@"TrackMetaData"][@"upnp:songAlbumID"];
|
|
|
+ }
|
|
|
+ NSString *channelString = resultDic[@"TrackMetaData"][@"upnp:songFlag"];
|
|
|
NSInteger songChannel = 0;
|
|
|
if ([channelString containsString:@"-"]) {
|
|
|
NSArray *channelStringArr = [channelString componentsSeparatedByString:@"-"];
|
|
@@ -533,31 +537,12 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
self.currentResource.songChannel = songChannel;
|
|
|
NSString *songChannelUid = [NSString stringWithFormat:@"%@-%@-%zd",self.userID,device.deviceUUID,songChannel];
|
|
|
self.currentResource.songChannelUid = songChannelUid;
|
|
|
- self.currentResource.songFlag = [NSString stringWithFormat:@"%@_%@_%zd",songChannelUid,dic[@"TrackMetaData"][@"upnp:songInfoID"],[dic[@"TrackMetaData"][@"upnp:songPlatform"] integerValue]];
|
|
|
+ self.currentResource.songFlag = [NSString stringWithFormat:@"%@_%@_%zd",songChannelUid,resultDic[@"TrackMetaData"][@"upnp:songInfoID"],[songFrom integerValue]];
|
|
|
}
|
|
|
});
|
|
|
return self.currentResource;
|
|
|
}
|
|
|
|
|
|
-//后台资源类型转成本地资源类型
|
|
|
-//type:1音乐直播 2直播电台 3音乐歌单 4主播电台 5音乐单曲 6电台节目 7电台精选
|
|
|
-- (MKRSourceType)convertSorceTypeWithAudioType:(NSInteger)type{
|
|
|
-
|
|
|
-#define ConvertSourceTypeCase(_value,_sourceType) case _value: \
|
|
|
- return _sourceType; \
|
|
|
- break;
|
|
|
- switch (type) {
|
|
|
- ConvertSourceTypeCase(1, MKRSourceTypeMusicRadio);
|
|
|
- ConvertSourceTypeCase(2, MKRSourceTypeBroadcast);
|
|
|
- ConvertSourceTypeCase(3, MKRSourceTypeMusic);
|
|
|
- ConvertSourceTypeCase(4, MKRSourceTypePodcast);
|
|
|
- ConvertSourceTypeCase(5, MKRSourceTypeMusic);
|
|
|
- ConvertSourceTypeCase(6, MKRSourceTypePodcast);
|
|
|
- ConvertSourceTypeCase(7, MKRSourceTypeHandPick);
|
|
|
- }
|
|
|
- return MKRSourceTypeMusic;
|
|
|
-}
|
|
|
-
|
|
|
- (id<MKRRadioResorce>)currentResource{
|
|
|
if (!_currentResource) {
|
|
|
_currentResource = [[MKRRadioResorce alloc] init];
|