1
我正在使用AVAudioPlayer或AVPlayer在我的應用程序中播放實時音頻流,但鏈接沒有擴展名,所以無論何時嘗試設置它,它都會失敗。有沒有人有什麼建議?沒有擴展名的iOS流音頻
代碼:
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];
}