Bladeren bron

版本升级维护

yyqxiaoyin 5 jaren geleden
bovenliggende
commit
deb9b4e08b

+ 2 - 0
MKRRadioManager/Classes/MKRRadioManager/MKRRadioResorce.h

@@ -33,6 +33,8 @@
 @property  (nonatomic, assign) NSInteger vip_canPlay;
 @property(nonatomic, strong) NSString *songChannelUid;
 @property(nonatomic, strong) NSString *songFlag;
+/** 资源的类型: 音乐  主播电台  广播电台 */
+@property (nonatomic, assign) MKRSourceType sourceType;
 /** 播放进度相关信息 */
 @property (nonatomic, strong) MKRPlayResourceStatus *resourceStatus;
 @end

+ 1 - 0
MKRRadioManager/Classes/MKRRadioManager/MKRRadioResorce.m

@@ -21,4 +21,5 @@
 @synthesize songChannelUid;
 @synthesize songFlag;
 @synthesize resourceStatus;
+@synthesize sourceType;
 @end

+ 27 - 43
MKRRadioManager/Classes/MKRRadioManager/MKRWIFIDeviceManager/MKRWIFIDeviceManager.m

@@ -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;
 }
 

+ 1 - 1
libs/libAS-Control.framework/Headers/ASControlTools.h

@@ -304,6 +304,6 @@ int libupnp_SetDuerAuthToken(NSString  *ControlURL,NSString *DuerAccessToken,NSS
 #pragma mark - 2.0
 
 
-- (NSString *)libupnp_getPlayInfo:(NSString *)controlUrl;
+- (NSDictionary *)libupnp_getPlayInfo:(NSString *)controlUrl;
 
 @end

+ 20 - 0
libs/libAS-Control.framework/Headers/NSDictionary+MKRXml.h

@@ -0,0 +1,20 @@
+//
+//  NSDictionary+MKRXml.h
+//  libAS-Control
+//
+//  Created by yyqxiaoyin on 2019/10/23.
+//  Copyright © 2019 AirSmart. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface NSDictionary (MKRXml)
+
++ (nullable NSDictionary *)mkr_dictionaryWithXML:(id)xmlDataOrString;
+
+@end
+
+NS_ASSUME_NONNULL_END

BIN
libs/libAS-Control.framework/libAS-Control