在sonos iOS上清除队列时删除当前歌曲

时间:2016-09-19 19:08:04

标签: ios queue sonos

我正在使用sonos-objc类来控制iOS应用中的sonos

当我想播放曲目时,我会调用此方法“playSpotifyTrack”,并在清除队列后当前的歌曲仍在播放,并在完成后停留

我怎么能删除它?

------的解决方案 -------

- (void)playSpotifyTrack:(NSString *)track position:(int)position completion:(void (^)(NSDictionary *reponse, NSError *error))block {

    NSString *trackURI = [track stringByReplacingOccurrencesOfString:@":" withString:@"%%3a"];

    NSString *meta = [NSString stringWithFormat:
                      @"<DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"> \
                      <item id=\"10030020%@\" parentID=\"10030020\" restricted=\"true\"> \
                      <upnp:class>object.item.audioItem.musicTrack</upnp:class> \
                      <desc id=\"cdudn\" nameSpace=\"urn:schemas-rinconnetworks-com:metadata-1-0/\">SA_RINCON2311_X_#Svc2311-0-Token</desc> \
                      </item> \
                      </DIDL-Lite>", trackURI];

    meta = [[[meta stringByReplacingOccurrencesOfString:@"<" withString:@"&lt;"] stringByReplacingOccurrencesOfString:@">" withString:@"&gt;"] stringByReplacingOccurrencesOfString:@"\"" withString:@"&quot;"];

    [self
     upnp:@"/MediaRenderer/AVTransport/Control"
     soap_service:@"urn:schemas-upnp-org:service:AVTransport:1"
     soap_action:@"AddURIToQueue"
     soap_arguments:[NSString stringWithFormat:@"<InstanceID>0</InstanceID><EnqueuedURI>10060a6c%@</EnqueuedURI><EnqueuedURIMetaData>%@</EnqueuedURIMetaData><DesiredFirstTrackNumberEnqueued>%d</DesiredFirstTrackNumberEnqueued><EnqueueAsNext>0</EnqueueAsNext>", trackURI, meta, position]
     completion:^(id response, NSError *error) {
         if(error) {
             if(block) {
                 block(response, error);
                 return;
             }
         }
         [self playQueuePosition:position completion:block];
     }];
}

解决方法是我将曲目添加到队列然后通过调用“playQueuePosition”而不是直接播放来播放它

0 个答案:

没有答案