AVAudioPlayer または AVPlayer を使用してアプリ内でライブ オーディオ ストリームを再生しようとしていますが、リンクに拡張子がないため、設定しようとすると失敗します。誰か提案はありますか?
コード:
NSString *path = @"http://audio7.radioreference.com/24705802";
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:path]];
NSError *error;
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithData:data error:&error];
player.volume = 1.0f;
player.numberOfLoops = -1.0f;
[player prepareToPlay];
if (player == nil) {
NSLog(@"Error: %@ Description: %@", error.localizedDescription, error.description);
}
else {
[player play];
}