Selaa lähdekoodia

版本升级维护

yyqxiaoyin 5 vuotta sitten
vanhempi
commit
da0c879a40

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

@@ -376,43 +376,38 @@ static inline void wd_playControl_queue(void (^block)(void)){
     libupnp_Play(device.avTransportUrl);
 }
 
+- (void)_playPlayFlag:(NSString *)playFlag
+              device:(id <MKRUPnPDevice>)device
+           timeStamp:(NSTimeInterval)timeStamp{
+    NSString *playListUrl = [NSString stringWithFormat:@"%@/web/playlist",[ASControlTools sharedInstanceUPNP].myIp];
+    NSString *timestamp = [NSString stringWithFormat:@"%.0f", timeStamp];
+    NSString *userID = self.userID;
+    libupnp_PlayNumFlag(
+    device.avTransportUrl,
+    playFlag,
+    timestamp,
+    userID,
+    playListUrl,
+    @"1"
+    );
+}
+
 - (void)playSongWithChannelNO:(NSInteger)channelNO
                         index:(NSInteger)index
                        device:(id <MKRUPnPDevice>)device
                     timeStamp:(NSTimeInterval)timeStamp{
-    NSString *playFlag = [NSString stringWithFormat:@"%zd-%zd",channelNO,index];
-    NSString *playListUrl = [NSString stringWithFormat:@"%@/web/playlist",[ASControlTools sharedInstanceUPNP].myIp];
-    NSString *timestamp = [NSString stringWithFormat:@"%.0f", timeStamp];
-    NSString *userID = self.userID;
     wd_playControl_queue(^{
-        libupnp_PlayNumFlag(
-        device.avTransportUrl,
-        playFlag,
-        timestamp,
-        userID,
-        playListUrl,
-        @"1"
-        );
+        NSString *playFlag = [NSString stringWithFormat:@"%zd-%zd",channelNO,index];
+        [self _playPlayFlag:playFlag device:device timeStamp:timeStamp];
     });
-    
 }
 
 - (void)playSongWithChannelNO:(NSInteger)channelNO
                        device:(id <MKRUPnPDevice>)device
                     timeStamp:(NSTimeInterval)timeStamp{
-    NSString *playFlag = [NSString stringWithFormat:@"%zd",channelNO];
-    NSString *playListUrl = [NSString stringWithFormat:@"%@/web/playlist",[ASControlTools sharedInstanceUPNP].myIp];
-    NSString *timestamp = [NSString stringWithFormat:@"%.0f", timeStamp];
-    NSString *userID = self.userID;
     wd_playControl_queue(^{
-        libupnp_PlayNumFlag(
-        device.avTransportUrl,
-        playFlag,
-        timestamp,
-        userID,
-        playListUrl,
-        @"1"
-        );
+        NSString *playFlag = [NSString stringWithFormat:@"%zd",channelNO];
+        [self _playPlayFlag:playFlag device:device timeStamp:timeStamp];
     });
 }
 
@@ -426,7 +421,8 @@ static inline void wd_playControl_queue(void (^block)(void)){
     wd_playControl_queue(^{
         [[MKRWIFIDeviceManager shareManager] setM3UList:m3uModel];
         [self setAVTransportURIWithSong:songs[index] device:device];
-        [self playSongWithChannelNO:13 index:index device:device timeStamp:timeStamp];
+        NSString *playFlag = [NSString stringWithFormat:@"13-%zd",index];
+        [self _playPlayFlag:playFlag device:device timeStamp:timeStamp];
     });
 }
 
@@ -439,7 +435,7 @@ static inline void wd_playControl_queue(void (^block)(void)){
     wd_playControl_queue(^{
         [[MKRWIFIDeviceManager shareManager] setM3UList:m3uModel];
         [self setAVTransportURIWithSong:songs[0] device:device];
-        [self playSongWithChannelNO:13 device:device timeStamp:timeStamp];
+        [self _playPlayFlag:@"13" device:device timeStamp:timeStamp];
     });
 }