從服務器中直接播放音頻文件時它不播放,如果先播放本地文件再播放服務器的就可以。
//NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle] resourcePath]]];
NSURL *url = [NSURL URLWithString:@"http://celeritas-solutions.com/pah_brd_v1/productivo/1.mp3"];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = -1;
if (audioPlayer == nil)
NSLog([error description]);
else
[audioPlayer play];
AVPlayer * player = [AVPlayer playerWithURL:[NSURL URLWithString:@"YOUR URL"]];
[player play];
這樣看看