Parcourir la source

版本升级维护

yyqxiaoyin il y a 5 ans
Parent
commit
c8a78ede37

+ 8 - 0
MKRRadioManager/Classes/MKRRadioManager/MKRWIFIDeviceManager/MKRM3UListModel.h

@@ -45,5 +45,13 @@
 @property (nonatomic, assign) int endIndex;
 @property (nonatomic, assign) int m3uSize;
 
+
+/// 映射后台的资源类型到app的资源类型
++ (MKRSourceType)convertSorceTypeWithAudioType:(NSInteger)type;
+
+
+/// 映射app的资源类型到后台的资源类型
++ (NSInteger)convertAudioTypeWithSorceType:(MKRSourceType)sourceType;
+
 @end
 

+ 34 - 1
MKRRadioManager/Classes/MKRRadioManager/MKRWIFIDeviceManager/MKRM3UListModel.m

@@ -84,7 +84,7 @@
         [self.songIDList addObject:@(obj.songID).stringValue];
         NSString *songIDString = [NSString stringWithFormat:@"AIRSMART//ID_%zd//",obj.songID];
         [self.urlList addObject:songIDString];
-        NSString *songFrom = [NSString stringWithFormat:@"1//2//%zd//",obj.songID];
+        NSString *songFrom = [NSString stringWithFormat:@"1//%zd//%zd//",[self.class convertAudioTypeWithSorceType:obj.sourceType],obj.songID];
         [self.songFromList addObject:songFrom];
         [self.songAlbumIDList addObject:obj.songAlbumID?:@""];
     }];
@@ -109,4 +109,37 @@
     [self createM3UWithSongs:targetSongs];
 }
 
+//后台资源类型转成本地资源类型
+//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;
+}
+
++ (NSInteger)convertAudioTypeWithSorceType:(MKRSourceType)sourceType{
+    #define ConvertAudioTypeCase(_sourceType,_value) case _sourceType: \
+                                                    return _value; \
+                                                break;
+    switch (sourceType) {
+        ConvertAudioTypeCase(MKRSourceTypeMusic, 3);
+        ConvertAudioTypeCase(MKRSourceTypePodcast, 4);
+        ConvertAudioTypeCase(MKRSourceTypeBroadcast, 2);
+        ConvertAudioTypeCase(MKRSourceTypeHandPick, 7);
+        ConvertAudioTypeCase(MKRSourceTypeMusicRadio, 1);
+    }
+    return MKRSourceTypeMusic;
+}
+
 @end

+ 21 - 36
MKRRadioManager/Classes/MKRRadioManager/MKRWIFIDeviceManager/MKRWIFIDeviceManager.m

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

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

@@ -318,6 +318,7 @@ int libupnp_SetDuerAuthToken(NSString  *ControlURL,NSString *DuerAccessToken,NSS
 #pragma mark - 2.0
 
 
+/// 获取播放信息
 - (NSDictionary *)libupnp_getPlayInfo:(NSString *)controlUrl;
 
 @end

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