Utilizzando il seguente esempio di codice dalla pagina degli sviluppatori di SoundCloud, AVAudioPlayer inizierà la riproduzione dopo che la risposta SCRequest è stata ricevuta. A seconda della dimensione del file richiesto, questo potrebbe richiedere del tempo.
L'API SoundCloud di iOS offre una soluzione pre-buffer, in modo che sia possibile avviare la riproduzione audio prima che tutti i dati siano stati ricevuti o devo implementare una propria soluzione con l'aiuto di NSURLConnection per raggiungere questo obiettivo?Avvia la riproduzione del flusso audio SoundCloud in iOS utilizzando un pre-buffer
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *track = [self.tracks objectAtIndex:indexPath.row];
NSString *streamURL = [track objectForKey:@"stream_url"];
SCAccount *account = [SCSoundCloud account];
[SCRequest performMethod:SCRequestMethodGET
onResource:[NSURL URLWithString:streamURL]
usingParameters:nil
withAccount:account
sendingProgressHandler:nil
responseHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSError *playerError;
player = [[AVAudioPlayer alloc] initWithData:data error:&playerError];
[player prepareToPlay];
[player play];
}];
}
Avete una soluzione per questo problema? –
qualsiasi soluzione ho anche bloccato sullo stesso problema. –