|
@@ -11,6 +11,7 @@
|
|
|
#import <pthread.h>
|
|
|
#import <libAS-Control/ASControlTools.h>
|
|
|
#import <libAS-Control/NSDictionary+MKRXml.h>
|
|
|
+#import <NSHashTable+MKRRadioManagerAdd.h>
|
|
|
|
|
|
static inline void wd_main_queue(void (^block)(void)){
|
|
|
if (pthread_main_np()) {
|
|
@@ -177,15 +178,33 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
#pragma mark - ASControlDelegate
|
|
|
|
|
|
-(void)ReceivedPlayCallBack:(NSString *)nUDN{
|
|
|
- NSLog(@"%s",__func__);
|
|
|
+ NSLog(@"收到播放回调%@",nUDN);
|
|
|
+ wd_main_queue(^{
|
|
|
+ if ([nUDN isEqualToString:self.device.deviceUUID]) {
|
|
|
+ self.currentResource.resourceStatus.playState = MKRResourcePlayStatePlaying;
|
|
|
+ [self.listeners makeObjectsPerformSelectorWithObjects:@selector(didReceivePlayStateChange:),MKRResourcePlayStatePlaying];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-(void)ReceivedPauseCallBack:(NSString *)nUDN{
|
|
|
- NSLog(@"%s",__func__);
|
|
|
+ NSLog(@"收到暂停回调%@",nUDN);
|
|
|
+ wd_main_queue(^{
|
|
|
+ if ([nUDN isEqualToString:self.device.deviceUUID]) {
|
|
|
+ self.currentResource.resourceStatus.playState = MKRResourcePlayStatePause;
|
|
|
+ [self.listeners makeObjectsPerformSelectorWithObjects:@selector(didReceivePlayStateChange:),MKRResourcePlayStatePause];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-(void)ReceivedStopCallBack:(NSString *)nUDN{
|
|
|
- NSLog(@"%s",__func__);
|
|
|
+ NSLog(@"收到停止回调%@",nUDN);
|
|
|
+ wd_main_queue(^{
|
|
|
+ if ([nUDN isEqualToString:self.device.deviceUUID]) {
|
|
|
+ self.currentResource.resourceStatus.playState = MKRResourcePlayStateStopped;
|
|
|
+ [self.listeners makeObjectsPerformSelectorWithObjects:@selector(didReceivePlayStateChange:),MKRResourcePlayStateStopped];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-(void)ReceivedSetVolumeCallBack:(NSString *)nUDN Volume:(NSInteger)Volume{
|
|
@@ -259,6 +278,12 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
|
|
|
-(void)ReceivedChangeChannelCallBack:(NSString *)nUDN Channel:(NSString *)channel{
|
|
|
NSLog(@"%s",__func__);
|
|
|
+ NSLog(@"收到频道改变回调%@",nUDN);
|
|
|
+ wd_main_queue(^{
|
|
|
+ if ([nUDN isEqualToString:self.device.deviceUUID]) {
|
|
|
+ [self.listeners makeObjectsPerformSelectorWithObjects:@selector(didReceivePlayingChannelChange:),[channel integerValue]];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-(void)getLocalIp:(NSString *)Ip{
|
|
@@ -361,9 +386,10 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
NSString *timestamp = [NSString stringWithFormat:@"%.0f", [[NSDate date] timeIntervalSince1970]];
|
|
|
NSString *channelNumString = [NSString stringWithFormat:@"CHANNEL_UPDATE_%zd",song.songChannel];
|
|
|
NSString *userID = self.userID;
|
|
|
+ NSString *songUrlString = [NSString stringWithFormat:@"AIRSMART//ID_%zd//",song.songID];
|
|
|
libupnp_SetAVTransportURI(
|
|
|
device.avTransportUrl,
|
|
|
- song.songUrl?:@"",
|
|
|
+ songUrlString,
|
|
|
song.songName?:@"",
|
|
|
song.songArtist?:@"",
|
|
|
song.songAlbum?:@"",
|
|
@@ -398,7 +424,7 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
timestamp,
|
|
|
userID,
|
|
|
playListUrl,
|
|
|
- @"1"
|
|
|
+ @"0"
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -508,23 +534,45 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
return ;
|
|
|
}
|
|
|
@synchronized (self.currentResource) {
|
|
|
- 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";
|
|
|
+ if ([resultDic[@"TrackMetaData"][@"upnp:songName"] isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.songName = resultDic[@"TrackMetaData"][@"upnp:songName"];
|
|
|
+ }
|
|
|
+ if ([resultDic[@"TrackMetaData"][@"upnp:songPlayer"] isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.songArtist = resultDic[@"TrackMetaData"][@"upnp:songPlayer"];
|
|
|
+ }
|
|
|
+ if ([resultDic[@"TrackMetaData"][@"upnp:songThumb"] isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.songAlbumCover = resultDic[@"TrackMetaData"][@"upnp:songThumb"];
|
|
|
+ }
|
|
|
+ if ([resultDic[@"TrackMetaData"][@"upnp:songInfoID"] isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.songID = [resultDic[@"TrackMetaData"][@"upnp:songInfoID"] integerValue];
|
|
|
+ }
|
|
|
+ if ([resultDic[@"TrackMetaData"][@"upnp:songPlatform"] isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.songFrom = [resultDic[@"TrackMetaData"][@"upnp:songPlatform"] integerValue];
|
|
|
+ }
|
|
|
+ if ([resultDic[@"TrackDuration"] isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.resourceStatus.totalTime = [NSString secondsFromHHmmssFormatStrig:resultDic[@"TrackDuration"]];
|
|
|
+ }
|
|
|
+ if ([resultDic[@"RelTime"] isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.resourceStatus.currentTime = [NSString secondsFromHHmmssFormatStrig:resultDic[@"RelTime"]];
|
|
|
}
|
|
|
- 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;
|
|
|
- id songAlbumID = resultDic[@"TrackMetaData"][@"upnp:songAlbumID"];
|
|
|
- if ([songAlbumID isKindOfClass:NSString.class]) {
|
|
|
- self.currentResource.songAlbumID = resultDic[@"TrackMetaData"][@"upnp:songAlbumID"];
|
|
|
+ if ([resultDic[@"CurrentTransportState"] isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.resourceStatus.playState = [self.currentResource.resourceStatus updatePlayState:resultDic[@"CurrentTransportState"]];
|
|
|
+ }
|
|
|
+ if ([resultDic[@"TrackMetaData"][@"upnp:songType"] isKindOfClass:NSString.class]) {
|
|
|
+ NSInteger sourceType = [MKRM3UListModel convertSorceTypeWithAudioType:[resultDic[@"TrackMetaData"][@"upnp:songType"] integerValue]];
|
|
|
+ self.currentResource.sourceType = sourceType;
|
|
|
+ }
|
|
|
+ if ([resultDic[@"TrackMetaData"][@"upnp:songAlbumID"] isKindOfClass:NSString.class]) {
|
|
|
+ id songAlbumID = resultDic[@"TrackMetaData"][@"upnp:songAlbumID"];
|
|
|
+ if ([songAlbumID isKindOfClass:NSString.class]) {
|
|
|
+ self.currentResource.songAlbumID = resultDic[@"TrackMetaData"][@"upnp:songAlbumID"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ([resultDic[@"TrackMetaData"][@"upnp:songAlbumID"] isKindOfClass:NSString.class]) {
|
|
|
+ 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;
|
|
@@ -537,12 +585,16 @@ 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,resultDic[@"TrackMetaData"][@"upnp:songInfoID"],[songFrom integerValue]];
|
|
|
+ self.currentResource.songFlag = [NSString stringWithFormat:@"%@_%zd_%zd",songChannelUid,self.currentResource.songID,self.currentResource.songFrom];
|
|
|
}
|
|
|
});
|
|
|
return self.currentResource;
|
|
|
}
|
|
|
|
|
|
+- (void)mkr_setObject:(id)obj forKey:(NSString *)key{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
- (id<MKRRadioResorce>)currentResource{
|
|
|
if (!_currentResource) {
|
|
|
_currentResource = [[MKRRadioResorce alloc] init];
|