这是我的代码:
-(void)playCurrentTrack
{
[[AFSoundManager sharedManager] startStreamingRemoteAudioFromURL:[[Playlist sharedInstance] currentSong].URLString andBlock:^(int percentage, CGFloat elapsedTime, CGFloat timeRemaining, NSError *error, BOOL finished) {
if (!error) {
//some labels changing
} else {
NSLog(@"There has been an error playing the remote file: %@", [error description]);
}
}];
}
当我重新打开包含它的viewcontroller时,块中的代码停止执行。
-(void)startStreamingRemoteAudioFromURL:(NSString *)url andBlock:(progressBlock)block {
//Some code here
if (block) {
block(percentage, CMTimeGetSeconds(_player.currentItem.currentTime), timeRemaining, error, NO);
}
//some other code
}