我正在尝试制作一个在线音频播放器。但我无法使用 AVAudioPlayer 对象播放音频。请帮我。提前致谢。
这是我的音频播放器代码。 ================>>>
NSURL *url =[[NSURL alloc] initWithString:@"My Url"];
xPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
xPlayer.numberOfLoops = 0;
xPlayer.volume = 1.0f;
[xPlayer prepareToPlay];
[xPlayer play];
最佳答案
问:AVAudioPlayer 是否支持流式音频内容?
A:AVAudioPlayer 类不支持基于 HTTP URL 的流式音频。与 initWithContentsOfURL: 一起使用的 URL 必须是文件 URL (file://)。即本地路径。
来源:https://developer.apple.com/library/ios/qa/qa1634/_index.html
关于ios - 我正在尝试使用 AVAudioPlayer 从服务器播放音频,但文件未播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29390071/